Major revamp all around:

Profile system; Megred options/mapping; Button mode and Standard Mode; removed other touchpad modes; allow 360 controls on touchpad points;
Minor Changes: Color picker for light bar is more accurate, added keyboard popup for mapping, PS+Touching pad toggles sliding, added more mouse buttons + media keys

Signed-off-by: jays2kings <jays2kings@gmail.com>
This commit is contained in:
jays2kings 2014-04-27 15:32:09 -04:00
parent 41b9976a20
commit c443be85a7
66 changed files with 5842 additions and 2999 deletions

View File

@ -1,182 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using DS4Library;
namespace DS4Control
{
public class ButtonMouse : ITouchpadBehaviour
{
private int deviceNum;
private bool leftButton, middleButton, rightButton;
private DS4State s = new DS4State();
private bool buttonLock; // Toggled with a two-finger touchpad push, we accept and absorb button input without any fingers on a touchpad, helping with drag-and-drop.
private DS4Device dev = null;
private readonly MouseCursor cursor;
private readonly MouseWheel wheel;
public ButtonMouse(int deviceID, DS4Device d)
{
deviceNum = deviceID;
dev = d;
cursor = new MouseCursor(deviceNum);
wheel = new MouseWheel(deviceNum);
}
public override string ToString()
{
return "Button Mode";
}
public void touchesMoved(object sender, TouchpadEventArgs arg)
{
cursor.touchesMoved(arg);
wheel.touchesMoved(arg);
dev.getCurrentState(s);
synthesizeMouseButtons(false);
}
public void touchUnchanged(object sender, EventArgs unused)
{
dev.getCurrentState(s);
if (buttonLock || s.Touch1 || s.Touch2)
synthesizeMouseButtons(false);
}
public void touchesBegan(object sender, TouchpadEventArgs arg)
{
cursor.touchesBegan(arg);
wheel.touchesBegan(arg);
dev.getCurrentState(s);
synthesizeMouseButtons(false);
}
public void touchesEnded(object sender, TouchpadEventArgs arg)
{
dev.getCurrentState(s);
if (!buttonLock)
synthesizeMouseButtons(true);
}
private void synthesizeMouseButtons(bool justRelease)
{
bool previousLeftButton = leftButton, previousMiddleButton = middleButton, previousRightButton = rightButton;
if (justRelease)
{
leftButton = middleButton = rightButton = false;
}
else
{
leftButton = s.L1 || s.R1 || s.DpadLeft || s.Square;
middleButton = s.DpadUp || s.DpadDown || s.Triangle || s.Cross;
rightButton = s.DpadRight || s.Circle;
s.L1 = s.R1 = s.DpadLeft = s.Square = s.DpadUp = s.DpadDown = s.Triangle = s.Cross = s.DpadRight = s.Circle = false;
}
if (leftButton != previousLeftButton)
InputMethods.MouseEvent(leftButton ? InputMethods.MOUSEEVENTF_LEFTDOWN : InputMethods.MOUSEEVENTF_LEFTUP);
if (middleButton != previousMiddleButton)
InputMethods.MouseEvent(middleButton ? InputMethods.MOUSEEVENTF_MIDDLEDOWN : InputMethods.MOUSEEVENTF_MIDDLEUP);
if (rightButton != previousRightButton)
InputMethods.MouseEvent(rightButton ? InputMethods.MOUSEEVENTF_RIGHTDOWN : InputMethods.MOUSEEVENTF_RIGHTUP);
}
// touch area stuff
private bool leftDown, rightDown, upperDown;
private bool isLeft(Touch t)
{
return t.hwX < 1920 * 2 / 5;
}
private bool isRight(Touch t)
{
return t.hwX >= 1920 * 3 / 5;
}
public void touchButtonUp(object sender, TouchpadEventArgs arg)
{
if (upperDown)
{
mapTouchPad(DS4Controls.TouchUpper, true);
upperDown = false;
}
if (leftDown)
{
mapTouchPad(DS4Controls.TouchButton, true);
leftDown = false;
}
if (rightDown)
{
mapTouchPad(DS4Controls.TouchMulti, true);
rightDown = false;
}
dev.setRumble(0, 0);
}
public void touchButtonDown(object sender, TouchpadEventArgs arg)
{
byte leftRumble, rightRumble;
if (arg.touches == null) //No touches, finger on upper portion of touchpad
{
mapTouchPad(DS4Controls.TouchUpper, false);
upperDown = true;
leftRumble = rightRumble = 127;
}
else if (arg.touches.Length == 1)
{
if (isLeft(arg.touches[0]))
{
mapTouchPad(DS4Controls.TouchButton, false);
leftDown = true;
leftRumble = 63;
rightRumble = 0;
}
else if (isRight(arg.touches[0]))
{
mapTouchPad(DS4Controls.TouchMulti, false);
rightDown = true;
leftRumble = 0;
rightRumble = 63;
}
else
{
leftRumble = rightRumble = 0; // Ignore ambiguous pushes.
}
}
else
{
buttonLock = !buttonLock;
leftRumble = rightRumble = (byte)(buttonLock ? 255 : 63);
}
dev.setRumble(rightRumble, leftRumble); // sustain while pressed
}
bool mapTouchPad(DS4Controls padControl, bool release)
{
ushort key = Global.getCustomKey(padControl);
if (key == 0)
return false;
else
{
DS4KeyType keyType = Global.getCustomKeyType(padControl);
if (!release)
if (keyType.HasFlag(DS4KeyType.ScanCode))
InputMethods.performSCKeyPress(key);
else InputMethods.performKeyPress(key);
else
if (!keyType.HasFlag(DS4KeyType.Repeat))
if (keyType.HasFlag(DS4KeyType.ScanCode))
InputMethods.performSCKeyRelease(key);
else InputMethods.performKeyRelease(key);
return true;
}
}
public DS4State getDS4State()
{
return s;
}
}
}

View File

@ -9,7 +9,8 @@ namespace DS4Control
{ {
X360Device x360Bus; X360Device x360Bus;
DS4Device[] DS4Controllers = new DS4Device[4]; DS4Device[] DS4Controllers = new DS4Device[4];
TPadModeSwitcher[] modeSwitcher = new TPadModeSwitcher[4]; //TPadModeSwitcher[] modeSwitcher = new TPadModeSwitcher[4];
Mouse[] touchPad = new Mouse[4];
private bool running = false; private bool running = false;
private DS4State[] MappedState = new DS4State[4]; private DS4State[] MappedState = new DS4State[4];
private DS4State[] CurrentState = new DS4State[4]; private DS4State[] CurrentState = new DS4State[4];
@ -36,6 +37,7 @@ namespace DS4Control
PreviousState[i] = new DS4State(); PreviousState[i] = new DS4State();
ExposedState[i] = new DS4StateExposed(CurrentState[i]); ExposedState[i] = new DS4StateExposed(CurrentState[i]);
} }
GiveMouses();
} }
private void WarnExclusiveModeFailure(DS4Device device) private void WarnExclusiveModeFailure(DS4Device device)
@ -67,15 +69,19 @@ namespace DS4Control
LogDebug("Found Controller: " + device.MacAddress + " (" + device.ConnectionType + ")"); LogDebug("Found Controller: " + device.MacAddress + " (" + device.ConnectionType + ")");
WarnExclusiveModeFailure(device); WarnExclusiveModeFailure(device);
DS4Controllers[ind] = device; DS4Controllers[ind] = device;
device.Removal -= DS4Devices.On_Removal;
device.Removal += this.On_DS4Removal; device.Removal += this.On_DS4Removal;
TPadModeSwitcher m_switcher = new TPadModeSwitcher(device, ind); device.Removal += DS4Devices.On_Removal;
m_switcher.Debug += OnDebug; //TPadModeSwitcher m_switcher = new TPadModeSwitcher(device, ind);
modeSwitcher[ind] = m_switcher; //m_switcher.Debug += OnDebug;
//modeSwitcher[ind] = m_switcher;
touchPad[ind] = new Mouse(ind, device);
DS4Color color = Global.loadColor(ind); DS4Color color = Global.loadColor(ind);
device.LightBarColor = color; device.LightBarColor = color;
x360Bus.Plugin(ind + 1); x360Bus.Plugin(ind + 1);
device.Report += this.On_Report; device.Report += this.On_Report;
m_switcher.setMode(Global.getTouchEnabled(ind) ? 1 : 0); //m_switcher.setMode(Global.getInitialMode(ind));
TouchPadOn(ind, device);
ind++; ind++;
LogDebug("Controller: " + device.MacAddress + " is ready to use"); LogDebug("Controller: " + device.MacAddress + " is ready to use");
Log.LogToTray("Controller: " + device.MacAddress + " is ready to use"); Log.LogToTray("Controller: " + device.MacAddress + " is ready to use");
@ -100,15 +106,21 @@ namespace DS4Control
{ {
running = false; running = false;
LogDebug("Stopping X360 Controllers"); LogDebug("Stopping X360 Controllers");
bool anyUnplugged = false;
for (int i = 0; i < DS4Controllers.Length; i++) for (int i = 0; i < DS4Controllers.Length; i++)
{ {
if (DS4Controllers[i] != null) if (DS4Controllers[i] != null)
{ {
CurrentState[i].Battery = PreviousState[i].Battery = 0; // Reset for the next connection's initial status change.
x360Bus.Unplug(i + 1); x360Bus.Unplug(i + 1);
anyUnplugged = true;
DS4Controllers[i] = null; DS4Controllers[i] = null;
modeSwitcher[i] = null; //modeSwitcher[i] = null;
touchPad[i] = null;
} }
} }
if (anyUnplugged)
System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
x360Bus.Stop(); x360Bus.Stop();
LogDebug("Stopping DS4 Controllers"); LogDebug("Stopping DS4 Controllers");
DS4Devices.stopControllers(); DS4Devices.stopControllers();
@ -119,16 +131,10 @@ namespace DS4Control
} }
private volatile bool justRemoved; // inhibits HotPlug temporarily when a device is being torn down
public bool HotPlug() public bool HotPlug()
{ {
if (running) if (running)
{ {
if (justRemoved)
{
justRemoved = false;
System.Threading.Thread.Sleep(200);
}
DS4Devices.findControllers(); DS4Devices.findControllers();
IEnumerable<DS4Device> devices = DS4Devices.getDS4Controllers(); IEnumerable<DS4Device> devices = DS4Devices.getDS4Controllers();
foreach (DS4Device device in devices) foreach (DS4Device device in devices)
@ -150,14 +156,18 @@ namespace DS4Control
LogDebug("Found Controller: " + device.MacAddress + " (" + device.ConnectionType + ")"); LogDebug("Found Controller: " + device.MacAddress + " (" + device.ConnectionType + ")");
WarnExclusiveModeFailure(device); WarnExclusiveModeFailure(device);
DS4Controllers[Index] = device; DS4Controllers[Index] = device;
device.Removal -= DS4Devices.On_Removal;
device.Removal += this.On_DS4Removal; device.Removal += this.On_DS4Removal;
TPadModeSwitcher m_switcher = new TPadModeSwitcher(device, Index); device.Removal += DS4Devices.On_Removal;
m_switcher.Debug += OnDebug; //TPadModeSwitcher m_switcher = new TPadModeSwitcher(device, Index);
modeSwitcher[Index] = m_switcher; //m_switcher.Debug += OnDebug;
//modeSwitcher[Index] = m_switcher;
touchPad[Index] = new Mouse(Index, device);
device.LightBarColor = Global.loadColor(Index); device.LightBarColor = Global.loadColor(Index);
device.Report += this.On_Report; device.Report += this.On_Report;
x360Bus.Plugin(Index + 1); x360Bus.Plugin(Index + 1);
m_switcher.setMode(Global.getTouchEnabled(Index) ? 1 : 0); //m_switcher.setMode(Global.getInitialMode(Index));
TouchPadOn(Index, device);
LogDebug("Controller: " + device.MacAddress + " is ready to use"); LogDebug("Controller: " + device.MacAddress + " is ready to use");
Log.LogToTray("Controller: " + device.MacAddress + " is ready to use"); Log.LogToTray("Controller: " + device.MacAddress + " is ready to use");
break; break;
@ -167,31 +177,80 @@ namespace DS4Control
return true; return true;
} }
public void TouchPadOn(int ind, DS4Device device)
{
ITouchpadBehaviour tPad = touchPad[ind];
device.Touchpad.TouchButtonDown += tPad.touchButtonDown;
device.Touchpad.TouchButtonUp += tPad.touchButtonUp;
device.Touchpad.TouchesBegan += tPad.touchesBegan;
device.Touchpad.TouchesMoved += tPad.touchesMoved;
device.Touchpad.TouchesEnded += tPad.touchesEnded;
device.Touchpad.TouchUnchanged += tPad.touchUnchanged;
//LogDebug("Touchpad mode for " + device.MacAddress + " is now " + tmode.ToString());
//Log.LogToTray("Touchpad mode for " + device.MacAddress + " is now " + tmode.ToString());
Global.ControllerStatusChanged(this);
}
public string getDS4ControllerInfo(int index) public string getDS4ControllerInfo(int index)
{ {
if (DS4Controllers[index] != null) if (DS4Controllers[index] != null)
{ {
DS4Device d = DS4Controllers[index]; DS4Device d = DS4Controllers[index];
if (!d.IsAlive()) if (!d.IsAlive())
return null; // awaiting the first battery charge indication return "Connecting..."; // awaiting the first battery charge indication
String battery; String battery;
if (d.Charging) if (d.Charging)
{ {
if (d.Battery >= 100) if (d.Battery >= 100)
battery = "fully-charged"; battery = "Charged";
else else
battery = "charging at ~" + d.Battery + "%"; battery = "Charging:" + d.Battery + "%";
} }
else else
{ {
battery = "draining at ~" + d.Battery + "%"; battery = "Battery: " + d.Battery + "%";
} }
return d.MacAddress + " (" + d.ConnectionType + "), Battery is " + battery + ", Touchpad in " + modeSwitcher[index].ToString(); return d.MacAddress + " (" + d.ConnectionType + "), " + battery;
//return d.MacAddress + " (" + d.ConnectionType + "), Battery is " + battery + ", Touchpad in " + modeSwitcher[index].ToString();
} }
else else
return null; return String.Empty;
} }
public string getShortDS4ControllerInfo(int index)
{
if (DS4Controllers[index] != null)
{
DS4Device d = DS4Controllers[index];
String battery;
if (!d.IsAlive())
battery = "...";
if (d.Charging)
{
if (d.Battery >= 100)
battery = "Full";
else
battery = ">" + d.Battery + '%';
}
else
{
battery = d.Battery + "%";
}
return battery + ' ' + d.ConnectionType;
}
else
return "None";
}
/* public string[] getAvailableControllerModes(int index)
{
List<string> modes = new List<String>();
if (DS4Controllers[index] != null)
foreach (ITouchpadBehaviour mode in modeSwitcher[index].getAvailableModes())
modes.Add(mode.ToString());
return modes.ToArray();
}
public string getDS4ControllerMode(int index) public string getDS4ControllerMode(int index)
{ {
if (DS4Controllers[index] != null) if (DS4Controllers[index] != null)
@ -203,8 +262,9 @@ namespace DS4Control
} }
else else
return "couldn't find"; return "couldn't find";
} } */
private int XINPUT_UNPLUG_SETTLE_TIME = 250; // Inhibit races that occur with the asynchronous teardown of ScpVBus -> X360 driver instance.
//Called when DS4 is disconnected or timed out //Called when DS4 is disconnected or timed out
protected virtual void On_DS4Removal(object sender, EventArgs e) protected virtual void On_DS4Removal(object sender, EventArgs e)
{ {
@ -215,12 +275,14 @@ namespace DS4Control
ind = i; ind = i;
if (ind != -1) if (ind != -1)
{ {
justRemoved = true; CurrentState[ind].Battery = PreviousState[ind].Battery = 0; // Reset for the next connection's initial status change.
x360Bus.Unplug(ind + 1); x360Bus.Unplug(ind + 1);
LogDebug("Controller " + device.MacAddress + " was removed or lost connection"); LogDebug("Controller " + device.MacAddress + " was removed or lost connection");
Log.LogToTray("Controller " + device.MacAddress + " was removed or lost connection"); Log.LogToTray("Controller " + device.MacAddress + " was removed or lost connection");
System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
DS4Controllers[ind] = null; DS4Controllers[ind] = null;
modeSwitcher[ind] = null; //modeSwitcher[ind] = null;
touchPad[ind] = null;
Global.ControllerStatusChanged(this); Global.ControllerStatusChanged(this);
} }
} }
@ -242,31 +304,26 @@ namespace DS4Control
DS4State cState = CurrentState[ind]; DS4State cState = CurrentState[ind];
device.getPreviousState(PreviousState[ind]); device.getPreviousState(PreviousState[ind]);
DS4State pState = PreviousState[ind]; DS4State pState = PreviousState[ind];
if (pState.Battery != cState.Battery)
Global.ControllerStatusChanged(this);
if (modeSwitcher[ind].getCurrentMode() is ButtonMouse) //bool wasButtonMouse = modeSwitcher[ind].getCurrentMode() is ButtonMouse;
{
ButtonMouse mode = (ButtonMouse)modeSwitcher[ind].getCurrentMode();
// XXX so disgusting, need to virtualize this again
mode.getDS4State().Copy(cState);
}
else
{
device.getExposedState(ExposedState[ind], CurrentState[ind]);
cState = CurrentState[ind];
}
CheckForHotkeys(ind, cState, pState); CheckForHotkeys(ind, cState, pState);
//if (wasButtonMouse && modeSwitcher[ind].getCurrentMode() is ButtonMouse)
{
//ButtonMouse mode = (ButtonMouse)modeSwitcher[ind].getCurrentMode();
// XXX so disgusting, need to virtualize this again
// mode.getDS4State().CopyTo(cState);
}
if (Global.getHasCustomKeysorButtons(ind)) if (Global.getHasCustomKeysorButtons(ind))
{ {
Mapping.mapButtons(cState, pState, MappedState[ind]); Mapping.MapCustom(ind, cState, MappedState[ind]);
cState = MappedState[ind]; cState = MappedState[ind];
} }
// Update the GUI/whatever. // Update the GUI/whatever.
DS4LightBar.updateLightBar(device, ind); DS4LightBar.updateLightBar(device, ind);
if (pState.Battery != cState.Battery)
Global.ControllerStatusChanged(this);
x360Bus.Parse(cState, processingData[ind].Report, ind); x360Bus.Parse(cState, processingData[ind].Report, ind);
// We push the translated Xinput state, and simultaneously we // We push the translated Xinput state, and simultaneously we
@ -281,24 +338,49 @@ namespace DS4Control
setRumble(Small, Big, ind); setRumble(Small, Big, ind);
} }
} }
// Output any synthetic events.
Mapping.Commit(ind);
// Pull settings updates.
device.IdleTimeout = Global.getIdleDisconnectTimeout(ind);
} }
} }
public void GiveMouses()
{
Mapping.GetMouses(ref touchPad);
}
bool touchreleased = true;
protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State pState) protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State pState)
{ {
DS4Device d = DS4Controllers[deviceID]; DS4Device d = DS4Controllers[deviceID];
if (cState.Touch1 && !pState.Share && !pState.Options) if (cState.Touch1 && !pState.Share && !pState.Options)
{ {
if (cState.Share) if (cState.Share)
modeSwitcher[deviceID].previousMode(); Global.setTouchSensitivity(deviceID, 0);
else if (cState.Options) else if (cState.Options)
modeSwitcher[deviceID].nextMode(); Global.setTouchSensitivity(deviceID, 100);
} }
if (cState.Touch1 && pState.PS)
{
if (Global.getTouchSensitivity(deviceID) > 0 && touchreleased)
{
Global.setTouchSensitivity(deviceID, 0);
touchreleased = false;
}
else if (touchreleased)
{
Global.setTouchSensitivity(deviceID, 100);
touchreleased = false;
}
}
else
touchreleased = true;
} }
public virtual void LogDebug(String Data) public virtual void LogDebug(String Data)
{ {
Console.WriteLine(System.DateTime.UtcNow.ToString("o") + "> " + Data);
if (Debug != null) if (Debug != null)
{ {
DebugEventArgs args = new DebugEventArgs(Data); DebugEventArgs args = new DebugEventArgs(Data);
@ -322,7 +404,10 @@ namespace DS4Control
uint heavyBoosted = ((uint)heavyMotor * (uint)boost) / 100; uint heavyBoosted = ((uint)heavyMotor * (uint)boost) / 100;
if (heavyBoosted > 255) if (heavyBoosted > 255)
heavyBoosted = 255; heavyBoosted = 255;
DS4Controllers[deviceNum].setRumble((byte)lightBoosted, (byte)heavyBoosted); if (Global.getRumbleSwap(deviceNum))
DS4Controllers[deviceNum].setRumble((byte)heavyBoosted, (byte)lightBoosted);
else
DS4Controllers[deviceNum].setRumble((byte)lightBoosted, (byte)heavyBoosted);
} }
} }
} }

View File

@ -1,47 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using DS4Library;
namespace DS4Control
{
public class MouseCursorOnly : ITouchpadBehaviour
{
private int deviceNum;
private readonly MouseCursor cursor;
private readonly MouseWheel wheel;
public MouseCursorOnly(int deviceID)
{
deviceNum = deviceID;
cursor = new MouseCursor(deviceNum);
wheel = new MouseWheel(deviceNum);
}
public override string ToString()
{
return "Cursor Mode";
}
public void touchesMoved(object sender, TouchpadEventArgs arg)
{
cursor.touchesMoved(arg);
wheel.touchesMoved(arg);
}
public void touchesBegan(object sender, TouchpadEventArgs arg)
{
cursor.touchesBegan(arg);
wheel.touchesBegan(arg);
}
public void touchesEnded(object sender, TouchpadEventArgs arg) { }
public void touchButtonUp(object sender, TouchpadEventArgs arg) { }
public void touchButtonDown(object sender, TouchpadEventArgs arg) { }
public void touchUnchanged(object sender, EventArgs unused) { }
}
}

View File

@ -41,14 +41,9 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ButtonMouse.cs" />
<Compile Include="Log.cs" /> <Compile Include="Log.cs" />
<Compile Include="CursorOnlyMode.cs" />
<Compile Include="DragMouse.cs" />
<Compile Include="MouseCursor.cs" /> <Compile Include="MouseCursor.cs" />
<Compile Include="MouseWheel.cs" /> <Compile Include="MouseWheel.cs" />
<Compile Include="TouchpadDisabled.cs" />
<Compile Include="TPadModeSwitcher.cs" />
<Compile Include="DS4LightBar.cs" /> <Compile Include="DS4LightBar.cs" />
<Compile Include="Control.cs" /> <Compile Include="Control.cs" />
<Compile Include="InputMethods.cs" /> <Compile Include="InputMethods.cs" />

View File

@ -1,112 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using DS4Library;
using System.Threading;
namespace DS4Control
{
class DragMouse: Mouse
{
protected bool leftClick = false;
protected Timer timer;
private readonly MouseCursor cursor;
private readonly MouseWheel wheel;
public DragMouse(int deviceID):base(deviceID)
{
timer = new System.Threading.Timer((a) =>
{
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
leftClick = false;
}, null,
System.Threading.Timeout.Infinite,
System.Threading.Timeout.Infinite);
cursor = new MouseCursor(deviceNum);
wheel = new MouseWheel(deviceNum);
}
public override string ToString()
{
return "Drag Mode";
}
public override void touchesBegan(object sender, TouchpadEventArgs arg)
{
base.touchesBegan(sender, arg);
if (leftClick)
timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
}
public override void touchesEnded(object sender, TouchpadEventArgs arg)
{
if (Global.getTapSensitivity(deviceNum) != 0)
{
DateTime test = arg.timeStamp;
if (test <= (pastTime + TimeSpan.FromMilliseconds((double)Global.getTapSensitivity(deviceNum) * 2)) && !arg.touchButtonPressed)
{
if (Math.Abs(firstTouch.hwX - arg.touches[0].hwX) < 10 &&
Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 10)
{
if (leftClick)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
leftClick = true;
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN);
timer.Change(Global.getTapSensitivity(deviceNum) * 2, System.Threading.Timeout.Infinite);
}
}
else if (leftClick)
{
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
leftClick = false;
}
}
}
public override void touchButtonUp(object sender, TouchpadEventArgs arg)
{
if (arg.touches == null)
{
//No touches, finger on upper portion of touchpad
mapTouchPad(DS4Controls.TouchUpper, true);
}
else if (arg.touches.Length > 1)
mapTouchPad(DS4Controls.TouchMulti, true);
else if (!rightClick && arg.touches.Length == 1 && !mapTouchPad(DS4Controls.TouchButton, true))
{
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
leftClick = false;
}
}
public override void touchButtonDown(object sender, TouchpadEventArgs arg)
{
if (arg.touches == null)
{
//No touches, finger on upper portion of touchpad
if (!mapTouchPad(DS4Controls.TouchUpper))
InputMethods.performMiddleClick();
}
else if (!Global.getLowerRCOff(deviceNum) && arg.touches[0].hwX > (1920 * 3) / 4
&& arg.touches[0].hwY > (960 * 3) / 4)
{
rightClick = true;
InputMethods.performRightClick();
}
else if (arg.touches.Length > 1 && !mapTouchPad(DS4Controls.TouchMulti))
{
rightClick = true;
InputMethods.performRightClick();
}
else if (arg.touches.Length == 1 && !mapTouchPad(DS4Controls.TouchButton))
{
rightClick = false;
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN);
leftClick = true;
}
}
}
}

View File

@ -73,6 +73,21 @@ namespace DS4Control
} }
} }
public static void MouseEvent(uint mouseButton, int type)
{
lock (lockob)
{
sendInputs[0].Type = INPUT_MOUSE;
sendInputs[0].Data.Mouse.ExtraInfo = IntPtr.Zero;
sendInputs[0].Data.Mouse.Flags = mouseButton;
sendInputs[0].Data.Mouse.MouseData = (uint)type;
sendInputs[0].Data.Mouse.Time = 0;
sendInputs[0].Data.Mouse.X = 0;
sendInputs[0].Data.Mouse.Y = 0;
uint result = SendInput(1, sendInputs, Marshal.SizeOf(sendInputs[0]));
}
}
public static void performLeftClick() public static void performLeftClick()
{ {
lock (lockob) lock (lockob)
@ -121,6 +136,21 @@ namespace DS4Control
} }
} }
public static void performFourthClick()
{
lock (lockob)
{
sendInputs[0].Type = INPUT_MOUSE;
sendInputs[0].Data.Mouse.ExtraInfo = IntPtr.Zero;
sendInputs[0].Data.Mouse.Flags = 0;
sendInputs[0].Data.Mouse.Flags |= MOUSEEVENTF_XBUTTONDOWN | MOUSEEVENTF_XBUTTONUP;
sendInputs[0].Data.Mouse.MouseData = 1;
sendInputs[0].Data.Mouse.Time = 0;
sendInputs[0].Data.Mouse.X = 0;
sendInputs[0].Data.Mouse.Y = 0;
uint result = SendInput(1, sendInputs, Marshal.SizeOf(sendInputs[0]));
}
}
public static void performSCKeyPress(ushort key) public static void performSCKeyPress(ushort key)
{ {
lock (lockob) lock (lockob)
@ -244,7 +274,9 @@ namespace DS4Control
MOUSEEVENTF_LEFTDOWN = 2, MOUSEEVENTF_LEFTUP = 4, MOUSEEVENTF_LEFTDOWN = 2, MOUSEEVENTF_LEFTUP = 4,
MOUSEEVENTF_RIGHTDOWN = 8, MOUSEEVENTF_RIGHTUP = 16, MOUSEEVENTF_RIGHTDOWN = 8, MOUSEEVENTF_RIGHTUP = 16,
MOUSEEVENTF_MIDDLEDOWN = 32, MOUSEEVENTF_MIDDLEUP = 64, MOUSEEVENTF_MIDDLEDOWN = 32, MOUSEEVENTF_MIDDLEUP = 64,
MOUSEEVENTF_XBUTTONDOWN = 128, MOUSEEVENTF_XBUTTONUP = 256,
KEYEVENTF_KEYUP = 2, MOUSEEVENTF_WHEEL = 0x0800, MOUSEEVENTF_HWHEEL = 0x1000, KEYEVENTF_KEYUP = 2, MOUSEEVENTF_WHEEL = 0x0800, MOUSEEVENTF_HWHEEL = 0x1000,
MOUSEEVENTF_MIDDLEWDOWN = 0x0020, MOUSEEVENTF_MIDDLEWUP = 0x0040,
KEYEVENTF_SCANCODE = 0x0008, MAPVK_VK_TO_VSC = 0; KEYEVENTF_SCANCODE = 0x0008, MAPVK_VK_TO_VSC = 0;
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]

View File

@ -5,45 +5,338 @@ using System.Text;
using DS4Library; using DS4Library;
namespace DS4Control namespace DS4Control
{ {
class Mapping public class Mapping
{ {
public static void mapButtons(DS4State cState, DS4State prevState, DS4State MappedState) /*
* Represent the synthetic keyboard and mouse events. Maintain counts for each so we don't duplicate events.
*/
private class SyntheticState
{ {
foreach (KeyValuePair<DS4Controls, ushort> customKey in Global.getCustomKeys()) public struct MouseClick
{ {
DS4KeyType keyType = Global.getCustomKeyType(customKey.Key); public int leftCount, middleCount, rightCount, fourthCount, fifthCount, wUpCount, wDownCount;
bool PrevOn = getBoolMapping(customKey.Key, prevState); }
public MouseClick previousClicks, currentClicks;
public struct KeyPress
{
public int vkCount, scanCodeCount, repeatCount; // repeat takes priority over non-, and scancode takes priority over non-
}
public class KeyPresses
{
public KeyPress previous, current;
}
public Dictionary<UInt16, KeyPresses> keyPresses = new Dictionary<UInt16, KeyPresses>();
public void SavePrevious(bool performClear)
{
previousClicks = currentClicks;
if (performClear)
currentClicks.leftCount = currentClicks.middleCount = currentClicks.rightCount = currentClicks.fourthCount = currentClicks.fifthCount = currentClicks.wUpCount = currentClicks.wDownCount = 0;
foreach (KeyPresses kp in keyPresses.Values)
{
kp.previous = kp.current;
if (performClear)
kp.current.repeatCount = kp.current.scanCodeCount = kp.current.vkCount = 0;
}
}
}
private static SyntheticState globalState = new SyntheticState();
private static SyntheticState[] deviceState = { new SyntheticState(), new SyntheticState(), new SyntheticState(), new SyntheticState() };
// TODO When we disconnect, process a null/dead state to release any keys or buttons.
public static void Commit(int device)
{
SyntheticState state = deviceState[device];
lock (globalState)
{
globalState.currentClicks.leftCount += state.currentClicks.leftCount - state.previousClicks.leftCount;
if (globalState.currentClicks.leftCount != 0 && globalState.previousClicks.leftCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN);
else if (globalState.currentClicks.leftCount == 0 && globalState.previousClicks.leftCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
globalState.currentClicks.middleCount += state.currentClicks.middleCount - state.previousClicks.middleCount;
if (globalState.currentClicks.middleCount != 0 && globalState.previousClicks.middleCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEDOWN);
else if (globalState.currentClicks.middleCount == 0 && globalState.previousClicks.middleCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEUP);
globalState.currentClicks.rightCount += state.currentClicks.rightCount - state.previousClicks.rightCount;
if (globalState.currentClicks.rightCount != 0 && globalState.previousClicks.rightCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTDOWN);
else if (globalState.currentClicks.rightCount == 0 && globalState.previousClicks.rightCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTUP);
globalState.currentClicks.fourthCount += state.currentClicks.fourthCount - state.previousClicks.fourthCount;
if (globalState.currentClicks.fourthCount != 0 && globalState.previousClicks.fourthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 1);
else if (globalState.currentClicks.fourthCount == 0 && globalState.previousClicks.fourthCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 1);
globalState.currentClicks.fifthCount += state.currentClicks.fifthCount - state.previousClicks.fifthCount;
if (globalState.currentClicks.fifthCount != 0 && globalState.previousClicks.fifthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 2);
else if (globalState.currentClicks.fifthCount == 0 && globalState.previousClicks.fifthCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 2);
globalState.currentClicks.wUpCount += state.currentClicks.wUpCount - state.previousClicks.wUpCount;
if (globalState.currentClicks.wUpCount != 0 && globalState.previousClicks.wUpCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, 100);
globalState.currentClicks.wDownCount += state.currentClicks.wDownCount - state.previousClicks.wDownCount;
if (globalState.currentClicks.wDownCount != 0 && globalState.previousClicks.wDownCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, -100);
// Merge and synthesize all key presses/releases that are present in this device's mapping.
// TODO what about the rest? e.g. repeat keys really ought to be on some set schedule
foreach (KeyValuePair<UInt16, SyntheticState.KeyPresses> kvp in state.keyPresses)
{
SyntheticState.KeyPresses gkp;
if (globalState.keyPresses.TryGetValue(kvp.Key, out gkp))
{
gkp.current.vkCount += kvp.Value.current.vkCount - kvp.Value.previous.vkCount;
gkp.current.scanCodeCount += kvp.Value.current.scanCodeCount - kvp.Value.previous.scanCodeCount;
gkp.current.repeatCount += kvp.Value.current.repeatCount - kvp.Value.previous.repeatCount;
}
else
{
gkp = new SyntheticState.KeyPresses();
gkp.current = kvp.Value.current;
globalState.keyPresses[kvp.Key] = gkp;
}
if (gkp.current.vkCount + gkp.current.scanCodeCount != 0 && gkp.previous.vkCount + gkp.previous.scanCodeCount == 0)
{
if (gkp.current.scanCodeCount != 0)
InputMethods.performSCKeyPress(kvp.Key);
else
InputMethods.performKeyPress(kvp.Key);
}
else if (gkp.current.repeatCount != 0 || // repeat or SC/VK transition
((gkp.previous.scanCodeCount == 0) != (gkp.current.scanCodeCount == 0)))
{
if (gkp.previous.scanCodeCount != 0) // use the last type of VK/SC
InputMethods.performSCKeyRelease(kvp.Key);
else
InputMethods.performKeyRelease(kvp.Key);
if (gkp.current.scanCodeCount != 0)
InputMethods.performSCKeyPress(kvp.Key);
else
InputMethods.performKeyPress(kvp.Key);
}
else if (gkp.current.vkCount + gkp.current.scanCodeCount == 0 && gkp.previous.vkCount + gkp.previous.scanCodeCount != 0)
{
if (gkp.previous.scanCodeCount != 0) // use the last type of VK/SC
InputMethods.performSCKeyRelease(kvp.Key);
else
InputMethods.performKeyRelease(kvp.Key);
}
}
globalState.SavePrevious(false);
}
state.SavePrevious(true);
}
public enum Click { None, Left, Middle, Right, Fourth, Fifth, WUP, WDOWN };
public static void MapClick(int device, Click mouseClick)
{
switch (mouseClick)
{
case Click.Left:
deviceState[device].currentClicks.leftCount++;
break;
case Click.Middle:
deviceState[device].currentClicks.middleCount++;
break;
case Click.Right:
deviceState[device].currentClicks.rightCount++;
break;
case Click.Fourth:
deviceState[device].currentClicks.fourthCount++;
break;
case Click.Fifth:
deviceState[device].currentClicks.fifthCount++;
break;
case Click.WUP:
deviceState[device].currentClicks.wUpCount++;
break;
case Click.WDOWN:
deviceState[device].currentClicks.wDownCount++;
break;
}
}
/** Map the touchpad button state to mouse or keyboard events. */
public static void MapTouchpadButton(int device, DS4Controls what, Click mouseEventFallback, DS4State MappedState = null)
{
SyntheticState deviceState = Mapping.deviceState[device];
ushort key = Global.getCustomKey(device, what);
if (key != 0)
{
DS4KeyType keyType = Global.getCustomKeyType(device, what);
SyntheticState.KeyPresses kp;
if (!deviceState.keyPresses.TryGetValue(key, out kp))
deviceState.keyPresses[key] = kp = new SyntheticState.KeyPresses();
if (keyType.HasFlag(DS4KeyType.ScanCode))
kp.current.scanCodeCount++;
else
kp.current.vkCount++;
if (keyType.HasFlag(DS4KeyType.Repeat))
kp.current.repeatCount++;
}
else
{
X360Controls button = Global.getCustomButton(device, what);
switch (button)
{
case X360Controls.None:
switch (mouseEventFallback)
{
case Click.Left:
deviceState.currentClicks.leftCount++;
return;
case Click.Middle:
deviceState.currentClicks.middleCount++;
return;
case Click.Right:
deviceState.currentClicks.rightCount++;
return;
case Click.Fourth:
deviceState.currentClicks.fourthCount++;
return;
case Click.Fifth:
deviceState.currentClicks.fifthCount++;
return;
case Click.WUP:
deviceState.currentClicks.wUpCount++;
return;
case Click.WDOWN:
deviceState.currentClicks.wDownCount++;
return;
}
return;
case X360Controls.LeftMouse:
deviceState.currentClicks.leftCount++;
return;
case X360Controls.MiddleMouse:
deviceState.currentClicks.middleCount++;
return;
case X360Controls.RightMouse:
deviceState.currentClicks.rightCount++;
return;
case X360Controls.FourthMouse:
deviceState.currentClicks.fourthCount++;
return;
case X360Controls.FifthMouse:
deviceState.currentClicks.fifthCount++;
return;
case X360Controls.WUP:
deviceState.currentClicks.wUpCount++;
return;
case X360Controls.WDOWN:
deviceState.currentClicks.wDownCount++;
return;
case X360Controls.A:
MappedState.Cross = true;
return;
case X360Controls.B:
MappedState.Circle = true;
return;
case X360Controls.X:
MappedState.Square = true;
return;
case X360Controls.Y:
MappedState.Triangle = true;
return;
case X360Controls.LB:
MappedState.L1 = true;
return;
case X360Controls.LS:
MappedState.L3 = true;
return;
case X360Controls.RB:
MappedState.R1 = true;
return;
case X360Controls.RS:
MappedState.R3 = true;
return;
case X360Controls.DpadUp:
MappedState.DpadUp = true;
return;
case X360Controls.DpadDown:
MappedState.DpadDown = true;
return;
case X360Controls.DpadLeft:
MappedState.DpadLeft = true;
return;
case X360Controls.DpadRight:
MappedState.DpadRight = true;
return;
case X360Controls.Guide:
MappedState.PS = true;
return;
case X360Controls.Back:
MappedState.Share = true;
return;
case X360Controls.Start:
MappedState.Options = true;
return;
case X360Controls.LT:
if (MappedState.L2 == 0)
MappedState.L2 = 255;
return;
case X360Controls.RT:
if (MappedState.R2 == 0)
MappedState.R2 = 255;
return;
case X360Controls.Unbound:
return;
default:
if (MappedState == null)
return;
break;
}
}
}
/** Map DS4 Buttons/Axes to other DS4 Buttons/Axes (largely the same as Xinput ones) and to keyboard and mouse buttons. */
public static void MapCustom(int device, DS4State cState, DS4State MappedState)
{
cState.CopyTo(MappedState);
SyntheticState deviceState = Mapping.deviceState[device];
foreach (KeyValuePair<DS4Controls, ushort> customKey in Global.getCustomKeys(device))
{
DS4KeyType keyType = Global.getCustomKeyType(device, customKey.Key);
if (getBoolMapping(customKey.Key, cState)) if (getBoolMapping(customKey.Key, cState))
{ {
resetToDefaultValue(customKey.Key, cState); resetToDefaultValue(customKey.Key, MappedState);
if (!PrevOn) SyntheticState.KeyPresses kp;
{ if (!deviceState.keyPresses.TryGetValue(customKey.Value, out kp))
deviceState.keyPresses[customKey.Value] = kp = new SyntheticState.KeyPresses();
if (keyType.HasFlag(DS4KeyType.ScanCode))
InputMethods.performSCKeyPress(customKey.Value);
else InputMethods.performKeyPress(customKey.Value);
}
else if (keyType.HasFlag(DS4KeyType.Repeat))
if (keyType.HasFlag(DS4KeyType.ScanCode))
InputMethods.performSCKeyPress(customKey.Value);
else InputMethods.performKeyPress(customKey.Value);
}
else if (PrevOn)
if (keyType.HasFlag(DS4KeyType.ScanCode)) if (keyType.HasFlag(DS4KeyType.ScanCode))
InputMethods.performSCKeyRelease(customKey.Value); kp.current.scanCodeCount++;
else InputMethods.performKeyRelease(customKey.Value); else
kp.current.vkCount++;
if (keyType.HasFlag(DS4KeyType.Repeat))
kp.current.repeatCount++;
}
} }
cState.Copy(MappedState);
bool LX = false, LY = false, RX = false, RY = false; bool LX = false, LY = false, RX = false, RY = false;
MappedState.LX = 127; MappedState.LX = 127;
MappedState.LY = 127; MappedState.LY = 127;
MappedState.RX = 127; MappedState.RX = 127;
MappedState.RY = 127; MappedState.RY = 127;
foreach (KeyValuePair<DS4Controls, X360Controls> customButton in Global.getCustomButtons()) Dictionary<DS4Controls, X360Controls> customButtons = Global.getCustomButtons(device);
foreach (KeyValuePair<DS4Controls, X360Controls> customButton in customButtons)
resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped
foreach (KeyValuePair<DS4Controls, X360Controls> customButton in customButtons)
{ {
bool LXChanged = MappedState.LX == 127; bool LXChanged = MappedState.LX == 127;
bool LYChanged = MappedState.LY == 127; bool LYChanged = MappedState.LY == 127;
bool RXChanged = MappedState.RX == 127; bool RXChanged = MappedState.RX == 127;
@ -51,49 +344,64 @@ namespace DS4Control
switch (customButton.Value) switch (customButton.Value)
{ {
case X360Controls.A: case X360Controls.A:
MappedState.Cross = getBoolMapping(customButton.Key, cState); if (!MappedState.Cross)
MappedState.Cross = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.B: case X360Controls.B:
if (!MappedState.Circle)
MappedState.Circle = getBoolMapping(customButton.Key, cState); MappedState.Circle = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.X: case X360Controls.X:
if (!MappedState.Square)
MappedState.Square = getBoolMapping(customButton.Key, cState); MappedState.Square = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.Y: case X360Controls.Y:
if (!MappedState.Triangle)
MappedState.Triangle = getBoolMapping(customButton.Key, cState); MappedState.Triangle = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.LB: case X360Controls.LB:
if (!MappedState.L1)
MappedState.L1 = getBoolMapping(customButton.Key, cState); MappedState.L1 = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.LS: case X360Controls.LS:
MappedState.L3 = getBoolMapping(customButton.Key, cState); if (!MappedState.L3)
MappedState.L3 = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.RB: case X360Controls.RB:
MappedState.R1 = getBoolMapping(customButton.Key, cState); if (!MappedState.R1)
MappedState.R1 = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.RS: case X360Controls.RS:
MappedState.R3 = getBoolMapping(customButton.Key, cState); if (!MappedState.R3)
MappedState.R3 = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.DpadUp: case X360Controls.DpadUp:
MappedState.DpadUp = getBoolMapping(customButton.Key, cState); if (!MappedState.DpadUp)
MappedState.DpadUp = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.DpadDown: case X360Controls.DpadDown:
MappedState.DpadDown = getBoolMapping(customButton.Key, cState); if (!MappedState.DpadDown)
MappedState.DpadDown = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.DpadLeft: case X360Controls.DpadLeft:
MappedState.DpadLeft = getBoolMapping(customButton.Key, cState); if (!MappedState.DpadLeft)
MappedState.DpadLeft = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.DpadRight: case X360Controls.DpadRight:
MappedState.DpadRight = getBoolMapping(customButton.Key, cState); if (!MappedState.DpadRight)
MappedState.DpadRight = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.Guide: case X360Controls.Guide:
MappedState.PS = getBoolMapping(customButton.Key, cState); if (!MappedState.PS)
MappedState.PS = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.Back: case X360Controls.Back:
MappedState.Share = getBoolMapping(customButton.Key, cState); if (!MappedState.Share)
MappedState.Share = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.Start: case X360Controls.Start:
MappedState.Options = getBoolMapping(customButton.Key, cState); if (!MappedState.Options)
MappedState.Options = getBoolMapping(customButton.Key, cState);
break; break;
case X360Controls.LXNeg: case X360Controls.LXNeg:
if (LXChanged) if (LXChanged)
@ -158,31 +466,32 @@ namespace DS4Control
MappedState.R2 = getByteMapping(customButton.Key, cState); MappedState.R2 = getByteMapping(customButton.Key, cState);
break; break;
case X360Controls.LeftMouse: case X360Controls.LeftMouse:
bool PrevOn = getBoolMapping(customButton.Key, prevState); if (getBoolMapping(customButton.Key, cState))
bool CurOn = getBoolMapping(customButton.Key, cState); deviceState.currentClicks.leftCount++;
if (!PrevOn && CurOn)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN);
else if (PrevOn && !CurOn)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
break; break;
case X360Controls.RightMouse: case X360Controls.RightMouse:
PrevOn = getBoolMapping(customButton.Key, prevState); if (getBoolMapping(customButton.Key, cState))
CurOn = getBoolMapping(customButton.Key, cState); deviceState.currentClicks.rightCount++;
if (!PrevOn && CurOn)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTDOWN);
else if (PrevOn && !CurOn)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTUP);
break; break;
case X360Controls.MiddleMouse: case X360Controls.MiddleMouse:
PrevOn = getBoolMapping(customButton.Key, prevState); if (getBoolMapping(customButton.Key, cState))
CurOn = getBoolMapping(customButton.Key, cState); deviceState.currentClicks.middleCount++;
if (!PrevOn && CurOn)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEDOWN);
else if (PrevOn && !CurOn)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEUP);
break; break;
case X360Controls.Unbound: case X360Controls.FourthMouse:
resetToDefaultValue(customButton.Key, MappedState); if (getBoolMapping(customButton.Key, cState))
deviceState.currentClicks.fourthCount++;
break;
case X360Controls.FifthMouse:
if (getBoolMapping(customButton.Key, cState))
deviceState.currentClicks.fifthCount++;
break;
case X360Controls.WUP:
if (getBoolMapping(customButton.Key, cState))
deviceState.currentClicks.wUpCount++;
break;
case X360Controls.WDOWN:
if (getBoolMapping(customButton.Key, cState))
deviceState.currentClicks.wDownCount++;
break; break;
} }
} }
@ -196,7 +505,11 @@ namespace DS4Control
if (!RY) if (!RY)
MappedState.RY = cState.RY; MappedState.RY = cState.RY;
} }
static Mouse[] mouses;
public static void GetMouses(ref Mouse[] mouss)
{
mouses = mouss;
}
public static bool compare(byte b1, byte b2) public static bool compare(byte b1, byte b2)
{ {
if (Math.Abs(b1 - b2) > 10) if (Math.Abs(b1 - b2) > 10)
@ -205,8 +518,24 @@ namespace DS4Control
} }
return true; return true;
} }
static bool[] touchArea = { true, true, true, true };
public static byte getByteMapping(DS4Controls control, DS4State cState) public static byte getByteMapping(DS4Controls control, DS4State cState)
{ {
if (!cState.TouchButton)
for (int i = 0; i < 4; i++)
touchArea[i] = false;
if (!(touchArea[0] || touchArea[1] || touchArea[2] || touchArea[3]))
{
if (cState.Touch2)
touchArea[0] = true;
if (cState.TouchLeft && !cState.Touch2 && cState.Touch1)
touchArea[1] = true;
if (cState.TouchRight && !cState.Touch2 && cState.Touch1)
touchArea[2] = true;
if (!cState.Touch1)
touchArea[3] = true;
}
switch (control) switch (control)
{ {
case DS4Controls.Share: return (byte)(cState.Share ? 255 : 0); case DS4Controls.Share: return (byte)(cState.Share ? 255 : 0);
@ -235,11 +564,39 @@ namespace DS4Control
case DS4Controls.L2: return cState.L2; case DS4Controls.L2: return cState.L2;
case DS4Controls.R2: return cState.R2; case DS4Controls.R2: return cState.R2;
} }
if (cState.TouchButton)
{
if (control == DS4Controls.TouchMulti)
if (!(touchArea[1] || touchArea[2] || touchArea[3]))
return (byte)(touchArea[0] ? 255 : 0);
if (control == DS4Controls.TouchLeft)
if (!(touchArea[0] || touchArea[2] || touchArea[3]))
return (byte)(touchArea[1] ? 255 : 0);
if (control == DS4Controls.TouchRight)
if (!(touchArea[0] || touchArea[1] || touchArea[3]))
return (byte)(touchArea[2] ? 255 : 0);
if (control == DS4Controls.TouchUpper)
if (!(touchArea[0] || touchArea[1] || touchArea[2]))
return (byte)(touchArea[3] ? 255 : 0);
}
return 0; return 0;
} }
public static bool getBoolMapping(DS4Controls control, DS4State cState) public static bool getBoolMapping(DS4Controls control, DS4State cState)
{ {
if (!cState.TouchButton)
for (int i = 0; i < 4; i++)
touchArea[i] = false;
if (!(touchArea[0] || touchArea[1] || touchArea[2] || touchArea[3]))
{
if (cState.Touch2)
touchArea[0] = true;
if (cState.TouchLeft && !cState.Touch2 && cState.Touch1)
touchArea[1] = true;
if (cState.TouchRight && !cState.Touch2 && cState.Touch1)
touchArea[2] = true;
if (!cState.Touch1)
touchArea[3] = true;
}
switch (control) switch (control)
{ {
case DS4Controls.Share: return cState.Share; case DS4Controls.Share: return cState.Share;
@ -267,6 +624,22 @@ namespace DS4Control
case DS4Controls.RYPos: return cState.RY > 200; case DS4Controls.RYPos: return cState.RY > 200;
case DS4Controls.L2: return cState.L2 > 100; case DS4Controls.L2: return cState.L2 > 100;
case DS4Controls.R2: return cState.R2 > 100; case DS4Controls.R2: return cState.R2 > 100;
}
if (cState.TouchButton)
{
if (control == DS4Controls.TouchMulti)
if (!(touchArea[1] || touchArea[2] || touchArea[3]))
return touchArea[0];
if (control == DS4Controls.TouchLeft)
if (!(touchArea[0] || touchArea[2] || touchArea[3]))
return touchArea[1];
if (control == DS4Controls.TouchRight)
if (!(touchArea[0] || touchArea[1] || touchArea[3]))
return touchArea[2];
if (control == DS4Controls.TouchUpper)
if (!(touchArea[0] || touchArea[1] || touchArea[2]))
return touchArea[3];
} }
return false; return false;
} }
@ -279,6 +652,20 @@ namespace DS4Control
{ {
trueVal = 255; trueVal = 255;
} }
if (!cState.TouchButton)
for (int i = 0; i < 4; i++)
touchArea[i] = false;
if (!(touchArea[0] || touchArea[1] || touchArea[2] || touchArea[3]))
{
if (cState.Touch2)
touchArea[0] = true;
if (cState.TouchLeft && !cState.Touch2 && cState.Touch1)
touchArea[1] = true;
if (cState.TouchRight && !cState.Touch2 && cState.Touch1)
touchArea[2] = true;
if (!cState.Touch1)
touchArea[3] = true;
}
switch (control) switch (control)
{ {
case DS4Controls.Share: return (byte)(cState.Share ? trueVal : falseVal); case DS4Controls.Share: return (byte)(cState.Share ? trueVal : falseVal);
@ -328,6 +715,21 @@ namespace DS4Control
case DS4Controls.RYPos: return cState.RY; case DS4Controls.RYPos: return cState.RY;
} }
} }
if (cState.TouchButton)
{
if (control == DS4Controls.TouchMulti)
if (!(touchArea[1] || touchArea[2] || touchArea[3]))
return (byte)(touchArea[0] ? trueVal : falseVal);
if (control == DS4Controls.TouchLeft)
if (!(touchArea[0] || touchArea[2] || touchArea[3]))
return (byte)(touchArea[1] ? trueVal : falseVal);
if (control == DS4Controls.TouchRight)
if (!(touchArea[0] || touchArea[1] || touchArea[3]))
return (byte)(touchArea[2] ? trueVal : falseVal);
if (control == DS4Controls.TouchUpper)
if (!(touchArea[0] || touchArea[1] || touchArea[2]))
return (byte)(touchArea[3] ? trueVal : falseVal);
}
return 0; return 0;
} }
@ -363,6 +765,10 @@ namespace DS4Control
case DS4Controls.RYPos: cState.RY = 127; break; case DS4Controls.RYPos: cState.RY = 127; break;
case DS4Controls.L2: cState.L2 = 0; break; case DS4Controls.L2: cState.L2 = 0; break;
case DS4Controls.R2: cState.R2 = 0; break; case DS4Controls.R2: cState.R2 = 0; break;
//case DS4Controls.TouchButton: cState.TouchLeft = false; break;
//case DS4Controls.TouchMulti: cState.Touch2 = false; break;
//case DS4Controls.TouchRight: cState.TouchRight = false; break;
//case DS4Controls.TouchUpper: cState.TouchButton = false; break;
} }
} }

View File

@ -10,14 +10,16 @@ namespace DS4Control
{ {
protected DateTime pastTime; protected DateTime pastTime;
protected Touch firstTouch; protected Touch firstTouch;
private DS4State s = new DS4State();
protected int deviceNum; protected int deviceNum;
private DS4Device dev = null;
private readonly MouseCursor cursor; private readonly MouseCursor cursor;
private readonly MouseWheel wheel; private readonly MouseWheel wheel;
protected bool rightClick = false;
public Mouse(int deviceID) public Mouse(int deviceID, DS4Device d)
{ {
deviceNum = deviceID; deviceNum = deviceID;
dev = d;
cursor = new MouseCursor(deviceNum); cursor = new MouseCursor(deviceNum);
wheel = new MouseWheel(deviceNum); wheel = new MouseWheel(deviceNum);
} }
@ -27,11 +29,20 @@ namespace DS4Control
return "Standard Mode"; return "Standard Mode";
} }
protected virtual void MapClicks()
{
if (pushed != DS4Controls.None)
Mapping.MapTouchpadButton(deviceNum, pushed, clicked);
}
public virtual void touchesMoved(object sender, TouchpadEventArgs arg) public virtual void touchesMoved(object sender, TouchpadEventArgs arg)
{ {
cursor.touchesMoved(arg); cursor.touchesMoved(arg);
wheel.touchesMoved(arg); wheel.touchesMoved(arg);
//Log.LogToGui("moved to " + arg.touches[0].hwX + "," + arg.touches[0].hwY); //MapClicks();
dev.getCurrentState(s);
synthesizeMouseButtons();
//Console.WriteLine(arg.timeStamp.ToString("O") + " " + "moved to " + arg.touches[0].hwX + "," + arg.touches[0].hwY);
} }
public virtual void touchesBegan(object sender, TouchpadEventArgs arg) public virtual void touchesBegan(object sender, TouchpadEventArgs arg)
@ -40,87 +51,124 @@ namespace DS4Control
wheel.touchesBegan(arg); wheel.touchesBegan(arg);
pastTime = arg.timeStamp; pastTime = arg.timeStamp;
firstTouch = arg.touches[0]; firstTouch = arg.touches[0];
//Log.LogToGui("began at " + arg.touches[0].hwX + "," + arg.touches[0].hwY); dev.getCurrentState(s);
synthesizeMouseButtons();
//MapClicks();
//Console.WriteLine(arg.timeStamp.ToString("O") + " " + "began at " + arg.touches[0].hwX + "," + arg.touches[0].hwY);
} }
public virtual void touchesEnded(object sender, TouchpadEventArgs arg) public virtual void touchesEnded(object sender, TouchpadEventArgs arg)
{ {
//Log.LogToGui("ended at " + arg.touches[0].hwX + "," + arg.touches[0].hwY); //Console.WriteLine(arg.timeStamp.ToString("O") + " " + "ended at " + arg.touches[0].hwX + "," + arg.touches[0].hwY);
if (Global.getTapSensitivity(deviceNum) != 0) if (Global.getTapSensitivity(deviceNum) != 0)
{ {
DateTime test = arg.timeStamp; DateTime test = arg.timeStamp;
if (test <= (pastTime + TimeSpan.FromMilliseconds((double)Global.getTapSensitivity(deviceNum) * 2)) && !arg.touchButtonPressed) if (test <= (pastTime + TimeSpan.FromMilliseconds((double)Global.getTapSensitivity(deviceNum) * 2)) && !arg.touchButtonPressed)
{ {
if (Math.Abs(firstTouch.hwX - arg.touches[0].hwX) < 10 && if (Math.Abs(firstTouch.hwX - arg.touches[0].hwX) < 10 && Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 10)
Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 10) Mapping.MapClick(deviceNum, Mapping.Click.Left);
InputMethods.performLeftClick();
} }
} }
dev.getCurrentState(s);
//if (buttonLock)
synthesizeMouseButtons();
//MapClicks();
}
protected DS4Controls pushed = DS4Controls.None;
protected Mapping.Click clicked = Mapping.Click.None;
// touch area stuff
public bool leftDown, rightDown, upperDown, multiDown, lowerRDown;
private bool isLeft(Touch t)
{
return t.hwX < 1920 * 2 / 5;
}
private bool isRight(Touch t)
{
return t.hwX >= 1920 * 2 / 5;
}
public virtual void touchUnchanged(object sender, EventArgs unused)
{
//MapClicks();
dev.getCurrentState(s);
if (s.Touch1 || s.Touch2 || s.TouchButton)
synthesizeMouseButtons();
}
private DS4State remapped = new DS4State();
private void synthesizeMouseButtons()
{
//Mapping.MapCustom(deviceNum, s, remapped);
if (leftDown)
Mapping.MapTouchpadButton(deviceNum, DS4Controls.TouchLeft, Mapping.Click.Left, remapped);
if (upperDown)
Mapping.MapTouchpadButton(deviceNum, DS4Controls.TouchUpper, Mapping.Click.Middle, remapped);
if (rightDown)
Mapping.MapTouchpadButton(deviceNum, DS4Controls.TouchRight, Mapping.Click.Left, remapped);
if (multiDown)
Mapping.MapTouchpadButton(deviceNum, DS4Controls.TouchMulti, Mapping.Click.Right, remapped);
if (lowerRDown)
Mapping.MapClick(deviceNum, Mapping.Click.Right);
s = remapped;
//remapped.CopyTo(s);
} }
public virtual void touchButtonUp(object sender, TouchpadEventArgs arg) public virtual void touchButtonUp(object sender, TouchpadEventArgs arg)
{ {
if (arg.touches == null) pushed = DS4Controls.None;
{ upperDown = leftDown = rightDown = multiDown = false;
//No touches, finger on upper portion of touchpad dev.setRumble(0, 0);
mapTouchPad(DS4Controls.TouchUpper,true); dev.getCurrentState(s);
} if (s.Touch1 || s.Touch2)
else if (arg.touches.Length > 1) synthesizeMouseButtons();
mapTouchPad(DS4Controls.TouchMulti, true);
else if (!rightClick && arg.touches.Length == 1 && !mapTouchPad(DS4Controls.TouchButton, true))
{
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
}
} }
public virtual void touchButtonDown(object sender, TouchpadEventArgs arg) public virtual void touchButtonDown(object sender, TouchpadEventArgs arg)
{ {
//byte leftRumble, rightRumble;
if (arg.touches == null) if (arg.touches == null)
{ {
//No touches, finger on upper portion of touchpad //No touches, finger on upper portion of touchpad
if(!mapTouchPad(DS4Controls.TouchUpper)) //leftRumble = rightRumble = 0;
InputMethods.performMiddleClick(); upperDown = true;
} }
else if (!Global.getLowerRCOff(deviceNum) && arg.touches[0].hwX > (1920 * 3)/4 else if (arg.touches.Length > 1 )//|| (Global.getLowerRCOn(deviceNum) && arg.touches[0].hwX > (1920 * 3) / 4 && arg.touches[0].hwY > (960 * 3) / 4))
&& arg.touches[0].hwY > (960 * 3)/4)
{ {
rightClick = true; //leftRumble = rightRumble = 150;
InputMethods.performRightClick(); multiDown = true;
} }
else if (arg.touches.Length>1 && !mapTouchPad(DS4Controls.TouchMulti))
{
rightClick = true;
InputMethods.performRightClick();
}
else if (arg.touches.Length==1 && !mapTouchPad(DS4Controls.TouchButton))
{
rightClick = false;
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN);
}
}
public void touchUnchanged(object sender, EventArgs unused) { }
protected bool mapTouchPad(DS4Controls padControl, bool release = false)
{
ushort key = Global.getCustomKey(padControl);
if (key == 0)
return false;
else else
{ {
DS4KeyType keyType = Global.getCustomKeyType(padControl); if ((Global.getLowerRCOn(deviceNum) && arg.touches[0].hwX > (1920 * 3) / 4 && arg.touches[0].hwY > (960 * 3) / 4))
if (!release) Mapping.MapClick(deviceNum, Mapping.Click.Right);
if (keyType.HasFlag(DS4KeyType.ScanCode)) if (isLeft(arg.touches[0]))
InputMethods.performSCKeyPress(key); {
else InputMethods.performKeyPress(key); leftDown = true;
//leftRumble = 25;
//rightRumble = 0;
}
else if (isRight(arg.touches[0]))
{
rightDown = true;
//leftRumble = 0;
//rightRumble = 25;
}
else else
if (!keyType.HasFlag(DS4KeyType.Repeat)) {
if (keyType.HasFlag(DS4KeyType.ScanCode)) //leftRumble = rightRumble = 0; // Ignore ambiguous pushes.
InputMethods.performSCKeyRelease(key); }
else InputMethods.performKeyRelease(key);
return true;
} }
//dev.setRumble(rightRumble, leftRumble); // sustain while pressed
dev.getCurrentState(s);
synthesizeMouseButtons();
} }
public DS4State getDS4State()
{
return s;
}
} }
} }

View File

@ -48,35 +48,36 @@ namespace DS4Control
// Often the DS4's internal jitter compensation kicks in and starts hiding changes, ironically creating jitter... // Often the DS4's internal jitter compensation kicks in and starts hiding changes, ironically creating jitter...
deltaX = arg.touches[0].deltaX; deltaX = arg.touches[0].deltaX;
deltaY = arg.touches[0].deltaY; deltaY = arg.touches[0].deltaY;
// allow only very fine, slow motions, when changing direction // allow only very fine, slow motions, when changing direction, even from neutral
if (deltaX < -1) // TODO maybe just consume it completely?
if (deltaX <= -1)
{ {
if (horizontalDirection == Direction.Positive) if (horizontalDirection != Direction.Negative)
{ {
deltaX = -1; deltaX = -1;
horizontalRemainder = 0.0; horizontalRemainder = 0.0;
} }
} }
else if (deltaX > 1) else if (deltaX >= 1)
{ {
if (horizontalDirection == Direction.Negative) if (horizontalDirection != Direction.Positive)
{ {
deltaX = 1; deltaX = 1;
horizontalRemainder = 0.0; horizontalRemainder = 0.0;
} }
} }
if (deltaY < -1) if (deltaY <= -1)
{ {
if (verticalDirection == Direction.Positive) if (verticalDirection != Direction.Negative)
{ {
deltaY = -1; deltaY = -1;
verticalRemainder = 0.0; verticalRemainder = 0.0;
} }
} }
else if (deltaY > 1) else if (deltaY >= 1)
{ {
if (verticalDirection == Direction.Negative) if (verticalDirection != Direction.Positive)
{ {
deltaY = 1; deltaY = 1;
verticalRemainder = 0.0; verticalRemainder = 0.0;
@ -122,8 +123,8 @@ namespace DS4Control
if (yAction != 0 || xAction != 0) if (yAction != 0 || xAction != 0)
InputMethods.MoveCursorBy(xAction, yAction); InputMethods.MoveCursorBy(xAction, yAction);
horizontalDirection = xAction > 0.0 ? Direction.Positive : xAction < 0.0 ? Direction.Negative : Direction.Neutral; horizontalDirection = xMotion > 0.0 ? Direction.Positive : xMotion < 0.0 ? Direction.Negative : Direction.Neutral;
verticalDirection = yAction > 0.0 ? Direction.Positive : yAction < 0.0 ? Direction.Negative : Direction.Neutral; verticalDirection = yMotion > 0.0 ? Direction.Positive : yMotion < 0.0 ? Direction.Negative : Direction.Neutral;
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -14,11 +14,11 @@ namespace DS4Control
public TPadModeSwitcher(DS4Device device, int deviceID) public TPadModeSwitcher(DS4Device device, int deviceID)
{ {
this.device = device; this.device = device;
modes.Add(TouchpadDisabled.singleton); //modes.Add(TouchpadDisabled.singleton);
modes.Add(new Mouse(deviceID)); modes.Add(new Mouse(deviceID, device));
modes.Add(new ButtonMouse(deviceID, device)); //modes.Add(new ButtonMouse(deviceID, device));
modes.Add(new MouseCursorOnly(deviceID)); //modes.Add(new MouseCursorOnly(deviceID));
modes.Add(new DragMouse(deviceID)); //modes.Add(new DragMouse(deviceID));
} }
public void switchMode(int ind) public void switchMode(int ind)
@ -35,7 +35,7 @@ namespace DS4Control
public void setMode(int ind) public void setMode(int ind)
{ {
ITouchpadBehaviour tmode = modes.ElementAt(ind); ITouchpadBehaviour tmode = modes.ElementAt(ind % modes.Count);
device.Touchpad.TouchButtonDown += tmode.touchButtonDown; device.Touchpad.TouchButtonDown += tmode.touchButtonDown;
device.Touchpad.TouchButtonUp += tmode.touchButtonUp; device.Touchpad.TouchButtonUp += tmode.touchButtonUp;
device.Touchpad.TouchesBegan += tmode.touchesBegan; device.Touchpad.TouchesBegan += tmode.touchesBegan;
@ -75,9 +75,14 @@ namespace DS4Control
Debug(this, new DebugEventArgs(data)); Debug(this, new DebugEventArgs(data));
} }
public ITouchpadBehaviour getCurrentMode() /*public ITouchpadBehaviour getCurrentMode()
{ {
return modes.ElementAt(currentTypeInd); return modes.ElementAt(currentTypeInd);
}*/
public ITouchpadBehaviour[] getAvailableModes()
{
return modes.ToArray();
} }
public int getCurrentModeInt() public int getCurrentModeInt()

View File

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DS4Library;
namespace DS4Control
{
class TouchpadDisabled : ITouchpadBehaviour
{
public override string ToString()
{
return "Disabled";
}
public static readonly TouchpadDisabled singleton = new TouchpadDisabled();
public void touchesMoved(object sender, TouchpadEventArgs arg) { }
public void touchesBegan(object sender, TouchpadEventArgs arg) { }
public void touchesEnded(object sender, TouchpadEventArgs arg) { }
public void touchButtonUp(object sender, TouchpadEventArgs arg) { }
public void touchButtonDown(object sender, TouchpadEventArgs arg) { }
public void touchUnchanged(object sender, EventArgs unused) { }
}
}

View File

@ -67,6 +67,7 @@ namespace DS4Library
private byte ledFlashOn, ledFlashOff; private byte ledFlashOn, ledFlashOff;
private Thread ds4Input, ds4Output; private Thread ds4Input, ds4Output;
private int battery; private int battery;
private DateTime lastActive = DateTime.UtcNow;
private bool charging; private bool charging;
public event EventHandler<EventArgs> Report = null; public event EventHandler<EventArgs> Report = null;
public event EventHandler<EventArgs> Removal = null; public event EventHandler<EventArgs> Removal = null;
@ -78,6 +79,7 @@ namespace DS4Library
public string MacAddress { get { return Mac; } } public string MacAddress { get { return Mac; } }
public ConnectionType ConnectionType { get { return conType; } } public ConnectionType ConnectionType { get { return conType; } }
public int IdleTimeout { get; set; } // behavior only active when > 0
public int Battery { get { return battery; } } public int Battery { get { return battery; } }
public bool Charging { get { return charging; } } public bool Charging { get { return charging; } }
@ -148,7 +150,6 @@ namespace DS4Library
public DS4Device(HidDevice hidDevice) public DS4Device(HidDevice hidDevice)
{ {
hDevice = hidDevice; hDevice = hidDevice;
hDevice.MonitorDeviceEvents = true;
conType = HidConnectionType(hDevice); conType = HidConnectionType(hDevice);
Mac = hDevice.readSerial(); Mac = hDevice.readSerial();
if (conType == ConnectionType.USB) if (conType == ConnectionType.USB)
@ -172,7 +173,7 @@ namespace DS4Library
if (ds4Input == null) if (ds4Input == null)
{ {
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> start"); Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> start");
sendOutputReport(true); // request the particular kind of input report we want sendOutputReport(true); // initialize the output report
ds4Output = new Thread(performDs4Output); ds4Output = new Thread(performDs4Output);
ds4Output.Name = "DS4 Output thread: " + Mac; ds4Output.Name = "DS4 Output thread: " + Mac;
ds4Output.Start(); ds4Output.Start();
@ -233,12 +234,26 @@ namespace DS4Library
{ {
lock (outputReport) lock (outputReport)
{ {
while (writeOutput()) int lastError = 0;
while (true)
{ {
if (testRumble.IsRumbleSet()) // repeat test rumbles periodically; rumble has auto-shut-off in the DS4 firmware if (writeOutput())
Monitor.Wait(outputReport, 10000); // DS4 firmware stops it after 5 seconds, so let the motors rest for that long, too. {
lastError = 0;
if (testRumble.IsRumbleSet()) // repeat test rumbles periodically; rumble has auto-shut-off in the DS4 firmware
Monitor.Wait(outputReport, 10000); // DS4 firmware stops it after 5 seconds, so let the motors rest for that long, too.
else
Monitor.Wait(outputReport);
}
else else
Monitor.Wait(outputReport); {
int thisError = Marshal.GetLastWin32Error();
if (lastError != thisError)
{
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> encountered write failure: " + thisError);
lastError = thisError;
}
}
} }
} }
} }
@ -251,29 +266,51 @@ namespace DS4Library
private byte priorInputReport30 = 0xff; private byte priorInputReport30 = 0xff;
private void performDs4Input() private void performDs4Input()
{ {
System.Timers.Timer readTimeout = new System.Timers.Timer(); // Await 30 seconds for the initial packet, then 3 seconds thereafter.
readTimeout.Elapsed += delegate { HidDevice.CancelIO(); };
while (true) while (true)
{ {
if (readTimeout.Interval != 3000.0)
{
if (readTimeout.Interval != 30000.0)
readTimeout.Interval = 30000.0;
else
readTimeout.Interval = 3000.0;
}
readTimeout.Enabled = true;
if (conType != ConnectionType.USB) if (conType != ConnectionType.USB)
if (hDevice.ReadFile(btInputReport) == HidDevice.ReadStatus.Success) {
HidDevice.ReadStatus res = hDevice.ReadFile(btInputReport);
readTimeout.Enabled = false;
if (res == HidDevice.ReadStatus.Success)
{ {
Array.Copy(btInputReport, 2, inputReport, 0, inputReport.Length); Array.Copy(btInputReport, 2, inputReport, 0, inputReport.Length);
} }
else else
{ {
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> disconnect"); Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> disconnect due to read failure: " + Marshal.GetLastWin32Error());
sendOutputReport(true); // Kick Windows into noticing the disconnection. sendOutputReport(true); // Kick Windows into noticing the disconnection.
StopOutputUpdate(); StopOutputUpdate();
if (!IsDisconnecting && Removal != null) IsDisconnecting = true;
if (Removal != null)
Removal(this, EventArgs.Empty); Removal(this, EventArgs.Empty);
return; return;
} }
else if (hDevice.ReadFile(inputReport) != HidDevice.ReadStatus.Success) }
else
{ {
StopOutputUpdate(); HidDevice.ReadStatus res = hDevice.ReadFile(inputReport);
if (!IsDisconnecting && Removal != null) readTimeout.Enabled = false;
Removal(this, EventArgs.Empty); if (res != HidDevice.ReadStatus.Success)
return; {
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> disconnect due to read failure: " + Marshal.GetLastWin32Error());
StopOutputUpdate();
IsDisconnecting = true;
if (Removal != null)
Removal(this, EventArgs.Empty);
return;
}
} }
if (ConnectionType == ConnectionType.BT && btInputReport[0] != 0x11) if (ConnectionType == ConnectionType.BT && btInputReport[0] != 0x11)
{ {
@ -282,8 +319,6 @@ namespace DS4Library
} }
DateTime utcNow = System.DateTime.UtcNow; // timestamp with UTC in case system time zone changes DateTime utcNow = System.DateTime.UtcNow; // timestamp with UTC in case system time zone changes
resetHapticState(); resetHapticState();
if (cState == null)
cState = new DS4State();
cState.ReportTimeStamp = utcNow; cState.ReportTimeStamp = utcNow;
cState.LX = inputReport[1]; cState.LX = inputReport[1];
cState.LY = inputReport[2]; cState.LY = inputReport[2];
@ -355,7 +390,9 @@ namespace DS4Library
cState.Touch1Identifier = (byte)(inputReport[0 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] & 0x7f); cState.Touch1Identifier = (byte)(inputReport[0 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] & 0x7f);
cState.Touch2 = (inputReport[4 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] >> 7) != 0 ? false : true; // 2 touches detected cState.Touch2 = (inputReport[4 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] >> 7) != 0 ? false : true; // 2 touches detected
cState.Touch2Identifier = (byte)(inputReport[4 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] & 0x7f); cState.Touch2Identifier = (byte)(inputReport[4 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] & 0x7f);
// Even when idling there is still a touch packet indicating no touch 1 or 2 cState.TouchLeft = (inputReport[1 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] + ((inputReport[2 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] & 0xF) * 255) >= 1920 * 2 / 5) ? false : true;
cState.TouchRight = (inputReport[1 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] + ((inputReport[2 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] & 0xF) * 255) < 1920 * 2 / 5) ? false : true;
// Even when idling there is still a touch packet indicating no touch 1 or 2
touchpad.handleTouchpad(inputReport, cState, touchOffset); touchpad.handleTouchpad(inputReport, cState, touchOffset);
} }
@ -368,9 +405,26 @@ namespace DS4Library
Console.WriteLine(); Console.WriteLine();
} */ } */
if (conType == ConnectionType.BT && (!pState.PS || !pState.Options) && cState.PS && cState.Options) if (conType == ConnectionType.BT)
{ {
if (DisconnectBT()) bool shouldDisconnect = false;
if ((!pState.PS || !pState.Options) && cState.PS && cState.Options)
{
shouldDisconnect = true;
}
else if (IdleTimeout > 0)
{
if (!isNonSixaxisIdle())
{
lastActive = utcNow;
}
else
{
DateTime timeout = lastActive + TimeSpan.FromSeconds(IdleTimeout);
shouldDisconnect = utcNow >= timeout;
}
}
if (shouldDisconnect && DisconnectBT())
return; // all done return; // all done
} }
// XXX fix initialization ordering so the null checks all go away // XXX fix initialization ordering so the null checks all go away
@ -378,9 +432,7 @@ namespace DS4Library
Report(this, EventArgs.Empty); Report(this, EventArgs.Empty);
sendOutputReport(false); sendOutputReport(false);
if (pState == null) cState.CopyTo(pState);
pState = new DS4State();
cState.Copy(pState);
} }
} }
@ -420,7 +472,8 @@ namespace DS4Library
outputReportBuffer.CopyTo(outputReport, 0); outputReportBuffer.CopyTo(outputReport, 0);
try try
{ {
writeOutput(); if (!writeOutput())
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> encountered synchronous write failure: " + Marshal.GetLastWin32Error());
} }
catch catch
{ {
@ -445,7 +498,7 @@ namespace DS4Library
{ {
if (Mac != null) if (Mac != null)
{ {
Console.WriteLine("Trying to disonnect BT device"); Console.WriteLine("Trying to disconnect BT device " + Mac);
IntPtr btHandle = IntPtr.Zero; IntPtr btHandle = IntPtr.Zero;
int IOCTL_BTH_DISCONNECT_DEVICE = 0x41000c; int IOCTL_BTH_DISCONNECT_DEVICE = 0x41000c;
@ -517,19 +570,40 @@ namespace DS4Library
public void getExposedState(DS4StateExposed expState, DS4State state) public void getExposedState(DS4StateExposed expState, DS4State state)
{ {
cState.Copy(state); cState.CopyTo(state);
expState.Accel = accel; expState.Accel = accel;
expState.Gyro = gyro; expState.Gyro = gyro;
} }
public void getCurrentState(DS4State state) public void getCurrentState(DS4State state)
{ {
cState.Copy(state); cState.CopyTo(state);
} }
public void getPreviousState(DS4State state) public void getPreviousState(DS4State state)
{ {
pState.Copy(state); pState.CopyTo(state);
}
private bool isNonSixaxisIdle()
{
if (cState.Square || cState.Cross || cState.Circle || cState.Triangle)
return false;
if (cState.DpadUp || cState.DpadLeft || cState.DpadDown || cState.DpadRight)
return false;
if (cState.L3 || cState.R3 || cState.L1 || cState.R1 || cState.Share || cState.Options)
return false;
if (cState.L2 != 0 || cState.R2 != 0)
return false;
// TODO calibrate to get an accurate jitter and center-play range and centered position
const int slop = 64;
if (cState.LX <= 127 - slop || cState.LX >= 128 + slop || cState.LY <= 127 - slop || cState.LY >= 128 + slop)
return false;
if (cState.RX <= 127 - slop || cState.RX >= 128 + slop || cState.RY <= 127 - slop || cState.RY >= 128 + slop)
return false;
if (cState.Touch1 || cState.Touch2 || cState.TouchButton)
return false;
return true;
} }
private DS4HapticState[] hapticState = new DS4HapticState[1]; private DS4HapticState[] hapticState = new DS4HapticState[1];

View File

@ -11,7 +11,7 @@ namespace DS4Library
public bool Square, Triangle, Circle, Cross; public bool Square, Triangle, Circle, Cross;
public bool DpadUp, DpadDown, DpadLeft, DpadRight; public bool DpadUp, DpadDown, DpadLeft, DpadRight;
public bool L1, L3, R1, R3; public bool L1, L3, R1, R3;
public bool Share, Options, PS, Touch1, Touch2, TouchButton; public bool Share, Options, PS, Touch1, Touch2, TouchButton, TouchRight, TouchLeft;
public byte Touch1Identifier, Touch2Identifier; public byte Touch1Identifier, Touch2Identifier;
public byte LX, RX, LY, RY, L2, R2; public byte LX, RX, LY, RY, L2, R2;
public byte FrameCounter; // 0, 1, 2...62, 63, 0.... public byte FrameCounter; // 0, 1, 2...62, 63, 0....
@ -23,7 +23,7 @@ namespace DS4Library
Square = Triangle = Circle = Cross = false; Square = Triangle = Circle = Cross = false;
DpadUp = DpadDown = DpadLeft = DpadRight = false; DpadUp = DpadDown = DpadLeft = DpadRight = false;
L1 = L3 = R1 = R3 = false; L1 = L3 = R1 = R3 = false;
Share = Options = PS = Touch1 = Touch2 = TouchButton = false; Share = Options = PS = Touch1 = Touch2 = TouchButton = TouchRight = TouchLeft = false;
LX = RX = LY = RY = 127; LX = RX = LY = RY = 127;
L2 = R2 = 0; L2 = R2 = 0;
FrameCounter = 255; // only actually has 6 bits, so this is a null indicator FrameCounter = 255; // only actually has 6 bits, so this is a null indicator
@ -52,6 +52,8 @@ namespace DS4Library
Options = state.Options; Options = state.Options;
PS = state.PS; PS = state.PS;
Touch1 = state.Touch1; Touch1 = state.Touch1;
TouchRight = state.TouchRight;
TouchLeft = state.TouchLeft;
Touch1Identifier = state.Touch1Identifier; Touch1Identifier = state.Touch1Identifier;
Touch2 = state.Touch2; Touch2 = state.Touch2;
Touch2Identifier = state.Touch2Identifier; Touch2Identifier = state.Touch2Identifier;
@ -70,7 +72,7 @@ namespace DS4Library
return new DS4State(this); return new DS4State(this);
} }
public void Copy(DS4State state) public void CopyTo(DS4State state)
{ {
state.ReportTimeStamp = ReportTimeStamp; state.ReportTimeStamp = ReportTimeStamp;
state.Square = Square; state.Square = Square;
@ -94,6 +96,8 @@ namespace DS4Library
state.Touch1Identifier = Touch1Identifier; state.Touch1Identifier = Touch1Identifier;
state.Touch2 = Touch2; state.Touch2 = Touch2;
state.Touch2Identifier = Touch2Identifier; state.Touch2Identifier = Touch2Identifier;
state.TouchLeft = TouchLeft;
state.TouchRight = TouchRight;
state.TouchButton = TouchButton; state.TouchButton = TouchButton;
state.TouchPacketCounter = TouchPacketCounter; state.TouchPacketCounter = TouchPacketCounter;
state.LX = LX; state.LX = LX;

View File

@ -87,7 +87,6 @@ namespace DS4Library
TouchUnchanged(this, EventArgs.Empty); TouchUnchanged(this, EventArgs.Empty);
return; return;
} }
byte touchID1 = (byte)(data[0 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0x7F); byte touchID1 = (byte)(data[0 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0x7F);
byte touchID2 = (byte)(data[4 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0x7F); byte touchID2 = (byte)(data[4 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0x7F);
int currentX1 = data[1 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] + ((data[2 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0xF) * 255); int currentX1 = data[1 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] + ((data[2 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0xF) * 255);

View File

@ -1,775 +0,0 @@
namespace ScpServer
{
partial class CustomMapping
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox = new System.Windows.Forms.PictureBox();
this.btnLoad = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.cbRepeat = new System.Windows.Forms.CheckBox();
this.cbScanCode = new System.Windows.Forms.CheckBox();
this.bnCross = new System.Windows.Forms.Button();
this.bnCircle = new System.Windows.Forms.Button();
this.bnSquare = new System.Windows.Forms.Button();
this.bnTriangle = new System.Windows.Forms.Button();
this.bnR1 = new System.Windows.Forms.Button();
this.bnR2 = new System.Windows.Forms.Button();
this.bnL1 = new System.Windows.Forms.Button();
this.bnL2 = new System.Windows.Forms.Button();
this.bnUp = new System.Windows.Forms.Button();
this.bnDown = new System.Windows.Forms.Button();
this.bnRight = new System.Windows.Forms.Button();
this.bnLeft = new System.Windows.Forms.Button();
this.bnOptions = new System.Windows.Forms.Button();
this.bnShare = new System.Windows.Forms.Button();
this.bnTouchpad = new System.Windows.Forms.Button();
this.bnPS = new System.Windows.Forms.Button();
this.bnTouchUpper = new System.Windows.Forms.Button();
this.bnTouchMulti = new System.Windows.Forms.Button();
this.bnLY = new System.Windows.Forms.Button();
this.lbControls = new System.Windows.Forms.ListBox();
this.bnLY2 = new System.Windows.Forms.Button();
this.bnRY = new System.Windows.Forms.Button();
this.bnRY2 = new System.Windows.Forms.Button();
this.bnLX = new System.Windows.Forms.Button();
this.bnLX2 = new System.Windows.Forms.Button();
this.bnRX = new System.Windows.Forms.Button();
this.bnRX2 = new System.Windows.Forms.Button();
this.bnL3 = new System.Windows.Forms.Button();
this.bnR3 = new System.Windows.Forms.Button();
this.TouchTip = new System.Windows.Forms.Label();
this.ReapTip = new System.Windows.Forms.Label();
this.lbMode = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout();
//
// pictureBox
//
this.pictureBox.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pictureBox.Enabled = false;
this.pictureBox.Image = global::ScpServer.Properties.Resources._1;
this.pictureBox.Location = new System.Drawing.Point(16, 67);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(396, 214);
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
//
// btnLoad
//
this.btnLoad.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnLoad.Location = new System.Drawing.Point(530, 12);
this.btnLoad.Name = "btnLoad";
this.btnLoad.Size = new System.Drawing.Size(65, 21);
this.btnLoad.TabIndex = 24;
this.btnLoad.Text = "Load";
this.btnLoad.UseVisualStyleBackColor = true;
this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
//
// btnSave
//
this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnSave.Location = new System.Drawing.Point(601, 12);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(65, 21);
this.btnSave.TabIndex = 25;
this.btnSave.Text = "Save";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// cbRepeat
//
this.cbRepeat.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.cbRepeat.AutoSize = true;
this.cbRepeat.ForeColor = System.Drawing.SystemColors.ControlText;
this.cbRepeat.Location = new System.Drawing.Point(19, 12);
this.cbRepeat.Name = "cbRepeat";
this.cbRepeat.Size = new System.Drawing.Size(61, 17);
this.cbRepeat.TabIndex = 26;
this.cbRepeat.Text = "Repeat";
this.cbRepeat.UseVisualStyleBackColor = true;
this.cbRepeat.CheckedChanged += new System.EventHandler(this.cbRepeat_CheckedChanged);
//
// cbScanCode
//
this.cbScanCode.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.cbScanCode.AutoSize = true;
this.cbScanCode.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cbScanCode.Location = new System.Drawing.Point(103, 12);
this.cbScanCode.Name = "cbScanCode";
this.cbScanCode.Size = new System.Drawing.Size(79, 17);
this.cbScanCode.TabIndex = 50;
this.cbScanCode.Text = "Scan Code";
this.cbScanCode.UseVisualStyleBackColor = true;
this.cbScanCode.CheckedChanged += new System.EventHandler(this.cbScanCode_CheckedChanged);
//
// bnCross
//
this.bnCross.BackColor = System.Drawing.Color.Transparent;
this.bnCross.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnCross.Cursor = System.Windows.Forms.Cursors.Default;
this.bnCross.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnCross.FlatAppearance.BorderSize = 0;
this.bnCross.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnCross.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnCross.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnCross.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnCross.Location = new System.Drawing.Point(323, 190);
this.bnCross.Name = "bnCross";
this.bnCross.Size = new System.Drawing.Size(23, 23);
this.bnCross.TabIndex = 53;
this.bnCross.Text = "A Button";
this.bnCross.UseVisualStyleBackColor = false;
//
// bnCircle
//
this.bnCircle.BackColor = System.Drawing.Color.Transparent;
this.bnCircle.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnCircle.Cursor = System.Windows.Forms.Cursors.Default;
this.bnCircle.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnCircle.FlatAppearance.BorderSize = 0;
this.bnCircle.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnCircle.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnCircle.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnCircle.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnCircle.Location = new System.Drawing.Point(350, 166);
this.bnCircle.Name = "bnCircle";
this.bnCircle.Size = new System.Drawing.Size(23, 23);
this.bnCircle.TabIndex = 53;
this.bnCircle.Text = "B Button";
this.bnCircle.UseVisualStyleBackColor = false;
//
// bnSquare
//
this.bnSquare.BackColor = System.Drawing.Color.Transparent;
this.bnSquare.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnSquare.Cursor = System.Windows.Forms.Cursors.Default;
this.bnSquare.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnSquare.FlatAppearance.BorderSize = 0;
this.bnSquare.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnSquare.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnSquare.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnSquare.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnSquare.Location = new System.Drawing.Point(294, 166);
this.bnSquare.Name = "bnSquare";
this.bnSquare.Size = new System.Drawing.Size(23, 23);
this.bnSquare.TabIndex = 53;
this.bnSquare.Text = "X Button";
this.bnSquare.UseVisualStyleBackColor = false;
//
// bnTriangle
//
this.bnTriangle.BackColor = System.Drawing.Color.Transparent;
this.bnTriangle.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnTriangle.Cursor = System.Windows.Forms.Cursors.Default;
this.bnTriangle.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnTriangle.FlatAppearance.BorderSize = 0;
this.bnTriangle.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnTriangle.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnTriangle.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnTriangle.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnTriangle.Location = new System.Drawing.Point(322, 140);
this.bnTriangle.Name = "bnTriangle";
this.bnTriangle.Size = new System.Drawing.Size(23, 23);
this.bnTriangle.TabIndex = 53;
this.bnTriangle.Text = "Y Button";
this.bnTriangle.UseVisualStyleBackColor = false;
//
// bnR1
//
this.bnR1.BackColor = System.Drawing.Color.Transparent;
this.bnR1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnR1.Cursor = System.Windows.Forms.Cursors.Default;
this.bnR1.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnR1.FlatAppearance.BorderSize = 0;
this.bnR1.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnR1.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnR1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnR1.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnR1.Location = new System.Drawing.Point(310, 90);
this.bnR1.Name = "bnR1";
this.bnR1.Size = new System.Drawing.Size(43, 15);
this.bnR1.TabIndex = 53;
this.bnR1.Text = "Right Bumper";
this.bnR1.UseVisualStyleBackColor = false;
//
// bnR2
//
this.bnR2.BackColor = System.Drawing.Color.Transparent;
this.bnR2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnR2.Cursor = System.Windows.Forms.Cursors.Default;
this.bnR2.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnR2.FlatAppearance.BorderSize = 0;
this.bnR2.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnR2.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnR2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnR2.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnR2.Location = new System.Drawing.Point(309, 65);
this.bnR2.Name = "bnR2";
this.bnR2.Size = new System.Drawing.Size(43, 20);
this.bnR2.TabIndex = 53;
this.bnR2.Text = "Right Trigger";
this.bnR2.UseVisualStyleBackColor = false;
//
// bnL1
//
this.bnL1.BackColor = System.Drawing.Color.Transparent;
this.bnL1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnL1.Cursor = System.Windows.Forms.Cursors.Default;
this.bnL1.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnL1.FlatAppearance.BorderSize = 0;
this.bnL1.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnL1.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnL1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnL1.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnL1.Location = new System.Drawing.Point(73, 88);
this.bnL1.Name = "bnL1";
this.bnL1.Size = new System.Drawing.Size(43, 15);
this.bnL1.TabIndex = 53;
this.bnL1.Text = "Left Bumper";
this.bnL1.UseVisualStyleBackColor = false;
//
// bnL2
//
this.bnL2.BackColor = System.Drawing.Color.Transparent;
this.bnL2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnL2.Cursor = System.Windows.Forms.Cursors.Default;
this.bnL2.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnL2.FlatAppearance.BorderSize = 0;
this.bnL2.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnL2.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnL2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnL2.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnL2.Location = new System.Drawing.Point(76, 66);
this.bnL2.Name = "bnL2";
this.bnL2.Size = new System.Drawing.Size(43, 20);
this.bnL2.TabIndex = 53;
this.bnL2.Text = "Left Trigger";
this.bnL2.UseVisualStyleBackColor = false;
//
// bnUp
//
this.bnUp.BackColor = System.Drawing.Color.Transparent;
this.bnUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnUp.Cursor = System.Windows.Forms.Cursors.Default;
this.bnUp.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnUp.FlatAppearance.BorderSize = 0;
this.bnUp.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnUp.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnUp.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnUp.Location = new System.Drawing.Point(84, 142);
this.bnUp.Name = "bnUp";
this.bnUp.Size = new System.Drawing.Size(19, 22);
this.bnUp.TabIndex = 53;
this.bnUp.Text = "Up Button";
this.bnUp.UseVisualStyleBackColor = false;
//
// bnDown
//
this.bnDown.BackColor = System.Drawing.Color.Transparent;
this.bnDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnDown.Cursor = System.Windows.Forms.Cursors.Default;
this.bnDown.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnDown.FlatAppearance.BorderSize = 0;
this.bnDown.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnDown.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnDown.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnDown.Location = new System.Drawing.Point(85, 184);
this.bnDown.Name = "bnDown";
this.bnDown.Size = new System.Drawing.Size(19, 29);
this.bnDown.TabIndex = 53;
this.bnDown.Text = "Down Button";
this.bnDown.UseVisualStyleBackColor = false;
//
// bnRight
//
this.bnRight.BackColor = System.Drawing.Color.Transparent;
this.bnRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnRight.Cursor = System.Windows.Forms.Cursors.Default;
this.bnRight.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnRight.FlatAppearance.BorderSize = 0;
this.bnRight.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnRight.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnRight.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnRight.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnRight.Location = new System.Drawing.Point(106, 164);
this.bnRight.Name = "bnRight";
this.bnRight.Size = new System.Drawing.Size(27, 22);
this.bnRight.TabIndex = 53;
this.bnRight.Text = "Right Button";
this.bnRight.UseVisualStyleBackColor = false;
//
// bnLeft
//
this.bnLeft.BackColor = System.Drawing.Color.Transparent;
this.bnLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnLeft.Cursor = System.Windows.Forms.Cursors.Default;
this.bnLeft.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnLeft.FlatAppearance.BorderSize = 0;
this.bnLeft.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnLeft.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnLeft.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnLeft.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnLeft.Location = new System.Drawing.Point(57, 163);
this.bnLeft.Name = "bnLeft";
this.bnLeft.Size = new System.Drawing.Size(26, 23);
this.bnLeft.TabIndex = 53;
this.bnLeft.Text = "Left Button";
this.bnLeft.UseVisualStyleBackColor = false;
//
// bnOptions
//
this.bnOptions.BackColor = System.Drawing.Color.Transparent;
this.bnOptions.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnOptions.Cursor = System.Windows.Forms.Cursors.Default;
this.bnOptions.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnOptions.FlatAppearance.BorderSize = 0;
this.bnOptions.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnOptions.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnOptions.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnOptions.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnOptions.Location = new System.Drawing.Point(286, 121);
this.bnOptions.Name = "bnOptions";
this.bnOptions.Size = new System.Drawing.Size(19, 30);
this.bnOptions.TabIndex = 53;
this.bnOptions.Text = "Start";
this.bnOptions.UseVisualStyleBackColor = false;
//
// bnShare
//
this.bnShare.BackColor = System.Drawing.Color.Transparent;
this.bnShare.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnShare.Cursor = System.Windows.Forms.Cursors.Default;
this.bnShare.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnShare.FlatAppearance.BorderSize = 0;
this.bnShare.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnShare.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnShare.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnShare.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnShare.Location = new System.Drawing.Point(131, 124);
this.bnShare.Name = "bnShare";
this.bnShare.Size = new System.Drawing.Size(14, 29);
this.bnShare.TabIndex = 53;
this.bnShare.Text = "Back";
this.bnShare.UseVisualStyleBackColor = false;
//
// bnTouchpad
//
this.bnTouchpad.BackColor = System.Drawing.Color.Transparent;
this.bnTouchpad.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnTouchpad.Cursor = System.Windows.Forms.Cursors.Default;
this.bnTouchpad.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnTouchpad.FlatAppearance.BorderSize = 0;
this.bnTouchpad.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnTouchpad.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnTouchpad.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnTouchpad.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnTouchpad.Location = new System.Drawing.Point(151, 135);
this.bnTouchpad.Name = "bnTouchpad";
this.bnTouchpad.Size = new System.Drawing.Size(64, 52);
this.bnTouchpad.TabIndex = 53;
this.bnTouchpad.Text = "Click";
this.bnTouchpad.UseVisualStyleBackColor = false;
//
// bnPS
//
this.bnPS.BackColor = System.Drawing.Color.Transparent;
this.bnPS.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnPS.Cursor = System.Windows.Forms.Cursors.Default;
this.bnPS.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnPS.FlatAppearance.BorderSize = 0;
this.bnPS.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnPS.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnPS.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnPS.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnPS.Location = new System.Drawing.Point(205, 208);
this.bnPS.Name = "bnPS";
this.bnPS.Size = new System.Drawing.Size(18, 18);
this.bnPS.TabIndex = 53;
this.bnPS.Text = "Guide";
this.bnPS.UseVisualStyleBackColor = false;
//
// bnTouchUpper
//
this.bnTouchUpper.BackColor = System.Drawing.Color.Transparent;
this.bnTouchUpper.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnTouchUpper.Cursor = System.Windows.Forms.Cursors.Default;
this.bnTouchUpper.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnTouchUpper.FlatAppearance.BorderSize = 0;
this.bnTouchUpper.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnTouchUpper.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnTouchUpper.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnTouchUpper.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnTouchUpper.Location = new System.Drawing.Point(150, 104);
this.bnTouchUpper.Name = "bnTouchUpper";
this.bnTouchUpper.Size = new System.Drawing.Size(129, 32);
this.bnTouchUpper.TabIndex = 53;
this.bnTouchUpper.Text = "Middle Click";
this.bnTouchUpper.UseVisualStyleBackColor = false;
//
// bnTouchMulti
//
this.bnTouchMulti.BackColor = System.Drawing.Color.Transparent;
this.bnTouchMulti.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnTouchMulti.Cursor = System.Windows.Forms.Cursors.Default;
this.bnTouchMulti.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnTouchMulti.FlatAppearance.BorderSize = 0;
this.bnTouchMulti.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnTouchMulti.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnTouchMulti.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnTouchMulti.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnTouchMulti.Location = new System.Drawing.Point(215, 135);
this.bnTouchMulti.Name = "bnTouchMulti";
this.bnTouchMulti.Size = new System.Drawing.Size(64, 52);
this.bnTouchMulti.TabIndex = 53;
this.bnTouchMulti.Text = "Right Click";
this.bnTouchMulti.UseVisualStyleBackColor = false;
//
// bnLY
//
this.bnLY.BackColor = System.Drawing.Color.Transparent;
this.bnLY.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnLY.Cursor = System.Windows.Forms.Cursors.Default;
this.bnLY.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnLY.FlatAppearance.BorderSize = 0;
this.bnLY.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnLY.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnLY.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnLY.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnLY.Location = new System.Drawing.Point(144, 213);
this.bnLY.Name = "bnLY";
this.bnLY.Size = new System.Drawing.Size(21, 10);
this.bnLY.TabIndex = 53;
this.bnLY.Text = "Left Y-Axis-";
this.bnLY.UseVisualStyleBackColor = false;
//
// lbControls
//
this.lbControls.FormattingEnabled = true;
this.lbControls.Items.AddRange(new object[] {
"<Click a button, then a key/item to assign>"});
this.lbControls.Location = new System.Drawing.Point(418, 67);
this.lbControls.Name = "lbControls";
this.lbControls.Size = new System.Drawing.Size(248, 212);
this.lbControls.TabIndex = 54;
//
// bnLY2
//
this.bnLY2.BackColor = System.Drawing.Color.Transparent;
this.bnLY2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnLY2.Cursor = System.Windows.Forms.Cursors.Default;
this.bnLY2.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnLY2.FlatAppearance.BorderSize = 0;
this.bnLY2.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnLY2.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnLY2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnLY2.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnLY2.Location = new System.Drawing.Point(144, 241);
this.bnLY2.Name = "bnLY2";
this.bnLY2.Size = new System.Drawing.Size(21, 10);
this.bnLY2.TabIndex = 53;
this.bnLY2.Text = "Left Y-Axis+";
this.bnLY2.UseVisualStyleBackColor = false;
//
// bnRY
//
this.bnRY.BackColor = System.Drawing.Color.Transparent;
this.bnRY.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnRY.Cursor = System.Windows.Forms.Cursors.Default;
this.bnRY.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnRY.FlatAppearance.BorderSize = 0;
this.bnRY.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnRY.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnRY.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnRY.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnRY.Location = new System.Drawing.Point(265, 213);
this.bnRY.Name = "bnRY";
this.bnRY.Size = new System.Drawing.Size(21, 10);
this.bnRY.TabIndex = 53;
this.bnRY.Text = "Right Y-Axis-";
this.bnRY.UseVisualStyleBackColor = false;
//
// bnRY2
//
this.bnRY2.BackColor = System.Drawing.Color.Transparent;
this.bnRY2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnRY2.Cursor = System.Windows.Forms.Cursors.Default;
this.bnRY2.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnRY2.FlatAppearance.BorderSize = 0;
this.bnRY2.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnRY2.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnRY2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnRY2.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnRY2.Location = new System.Drawing.Point(265, 241);
this.bnRY2.Name = "bnRY2";
this.bnRY2.Size = new System.Drawing.Size(21, 10);
this.bnRY2.TabIndex = 53;
this.bnRY2.Text = "Right Y-Axis+";
this.bnRY2.UseVisualStyleBackColor = false;
//
// bnLX
//
this.bnLX.BackColor = System.Drawing.Color.Transparent;
this.bnLX.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnLX.Cursor = System.Windows.Forms.Cursors.Default;
this.bnLX.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnLX.FlatAppearance.BorderSize = 0;
this.bnLX.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnLX.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnLX.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnLX.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnLX.Location = new System.Drawing.Point(131, 222);
this.bnLX.Name = "bnLX";
this.bnLX.Size = new System.Drawing.Size(10, 20);
this.bnLX.TabIndex = 53;
this.bnLX.Text = "Left X-Axis-";
this.bnLX.UseVisualStyleBackColor = false;
//
// bnLX2
//
this.bnLX2.BackColor = System.Drawing.Color.Transparent;
this.bnLX2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnLX2.Cursor = System.Windows.Forms.Cursors.Default;
this.bnLX2.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnLX2.FlatAppearance.BorderSize = 0;
this.bnLX2.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnLX2.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnLX2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnLX2.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnLX2.Location = new System.Drawing.Point(167, 222);
this.bnLX2.Name = "bnLX2";
this.bnLX2.Size = new System.Drawing.Size(10, 20);
this.bnLX2.TabIndex = 53;
this.bnLX2.Text = "Left X-Axis+";
this.bnLX2.UseVisualStyleBackColor = false;
//
// bnRX
//
this.bnRX.BackColor = System.Drawing.Color.Transparent;
this.bnRX.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnRX.Cursor = System.Windows.Forms.Cursors.Default;
this.bnRX.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnRX.FlatAppearance.BorderSize = 0;
this.bnRX.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnRX.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnRX.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnRX.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnRX.Location = new System.Drawing.Point(253, 222);
this.bnRX.Name = "bnRX";
this.bnRX.Size = new System.Drawing.Size(10, 20);
this.bnRX.TabIndex = 53;
this.bnRX.Text = "Right X-Axis-";
this.bnRX.UseVisualStyleBackColor = false;
//
// bnRX2
//
this.bnRX2.BackColor = System.Drawing.Color.Transparent;
this.bnRX2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnRX2.Cursor = System.Windows.Forms.Cursors.Default;
this.bnRX2.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnRX2.FlatAppearance.BorderSize = 0;
this.bnRX2.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnRX2.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnRX2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnRX2.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnRX2.Location = new System.Drawing.Point(289, 222);
this.bnRX2.Name = "bnRX2";
this.bnRX2.Size = new System.Drawing.Size(10, 20);
this.bnRX2.TabIndex = 53;
this.bnRX2.Text = "Right X-Axis+";
this.bnRX2.UseVisualStyleBackColor = false;
//
// bnL3
//
this.bnL3.BackColor = System.Drawing.Color.Transparent;
this.bnL3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnL3.Cursor = System.Windows.Forms.Cursors.Default;
this.bnL3.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnL3.FlatAppearance.BorderSize = 0;
this.bnL3.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnL3.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnL3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnL3.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnL3.Location = new System.Drawing.Point(147, 223);
this.bnL3.Name = "bnL3";
this.bnL3.Size = new System.Drawing.Size(16, 17);
this.bnL3.TabIndex = 53;
this.bnL3.Text = "Left Stick";
this.bnL3.UseVisualStyleBackColor = false;
//
// bnR3
//
this.bnR3.BackColor = System.Drawing.Color.Transparent;
this.bnR3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.bnR3.Cursor = System.Windows.Forms.Cursors.Default;
this.bnR3.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.bnR3.FlatAppearance.BorderSize = 0;
this.bnR3.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.Control;
this.bnR3.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control;
this.bnR3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.bnR3.ForeColor = System.Drawing.SystemColors.WindowText;
this.bnR3.Location = new System.Drawing.Point(267, 224);
this.bnR3.Name = "bnR3";
this.bnR3.Size = new System.Drawing.Size(16, 17);
this.bnR3.TabIndex = 53;
this.bnR3.Text = "Right Stick";
this.bnR3.UseVisualStyleBackColor = false;
//
// TouchTip
//
this.TouchTip.AutoSize = true;
this.TouchTip.Location = new System.Drawing.Point(141, 34);
this.TouchTip.MaximumSize = new System.Drawing.Size(151, 52);
this.TouchTip.MinimumSize = new System.Drawing.Size(151, 52);
this.TouchTip.Name = "TouchTip";
this.TouchTip.Size = new System.Drawing.Size(151, 52);
this.TouchTip.TabIndex = 55;
this.TouchTip.Text = "Touchpad (Standard Mode):\r\nTop: Upper Pad \r\nMiddle: Multi-Touch \r\nBottom: Single " +
"Touch";
this.TouchTip.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.TouchTip.Visible = false;
//
// ReapTip
//
this.ReapTip.AutoSize = true;
this.ReapTip.Location = new System.Drawing.Point(134, 59);
this.ReapTip.Name = "ReapTip";
this.ReapTip.Size = new System.Drawing.Size(169, 26);
this.ReapTip.TabIndex = 55;
this.ReapTip.Text = "Double Tap a key to toggle repeat\r\n(Excludes TouchPad)";
this.ReapTip.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.ReapTip.Visible = false;
//
// lbMode
//
this.lbMode.AutoSize = true;
this.lbMode.Location = new System.Drawing.Point(418, 51);
this.lbMode.Name = "lbMode";
this.lbMode.Size = new System.Drawing.Size(51, 13);
this.lbMode.TabIndex = 56;
this.lbMode.Text = "Controller";
this.lbMode.Visible = false;
//
// CustomMapping
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
this.ClientSize = new System.Drawing.Size(684, 310);
this.Controls.Add(this.TouchTip);
this.Controls.Add(this.ReapTip);
this.Controls.Add(this.pictureBox);
this.Controls.Add(this.lbMode);
this.Controls.Add(this.lbControls);
this.Controls.Add(this.cbScanCode);
this.Controls.Add(this.cbRepeat);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.btnLoad);
this.Controls.Add(this.bnL2);
this.Controls.Add(this.bnR2);
this.Controls.Add(this.bnL1);
this.Controls.Add(this.bnR1);
this.Controls.Add(this.bnLeft);
this.Controls.Add(this.bnRY2);
this.Controls.Add(this.bnRY);
this.Controls.Add(this.bnLY2);
this.Controls.Add(this.bnRX2);
this.Controls.Add(this.bnLX2);
this.Controls.Add(this.bnRX);
this.Controls.Add(this.bnLX);
this.Controls.Add(this.bnLY);
this.Controls.Add(this.bnRight);
this.Controls.Add(this.bnDown);
this.Controls.Add(this.bnR3);
this.Controls.Add(this.bnL3);
this.Controls.Add(this.bnPS);
this.Controls.Add(this.bnShare);
this.Controls.Add(this.bnTouchUpper);
this.Controls.Add(this.bnTouchMulti);
this.Controls.Add(this.bnTouchpad);
this.Controls.Add(this.bnOptions);
this.Controls.Add(this.bnUp);
this.Controls.Add(this.bnTriangle);
this.Controls.Add(this.bnSquare);
this.Controls.Add(this.bnCircle);
this.Controls.Add(this.bnCross);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(700, 349);
this.MinimumSize = new System.Drawing.Size(700, 349);
this.Name = "CustomMapping";
this.Text = "Custom Mapping";
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.CheckBox cbRepeat;
private System.Windows.Forms.Button btnLoad;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.CheckBox cbScanCode;
private System.Windows.Forms.Button bnCross;
private System.Windows.Forms.Button bnCircle;
private System.Windows.Forms.Button bnSquare;
private System.Windows.Forms.Button bnTriangle;
private System.Windows.Forms.Button bnR1;
private System.Windows.Forms.Button bnR2;
private System.Windows.Forms.Button bnL1;
private System.Windows.Forms.Button bnL2;
private System.Windows.Forms.Button bnUp;
private System.Windows.Forms.Button bnDown;
private System.Windows.Forms.Button bnRight;
private System.Windows.Forms.Button bnLeft;
private System.Windows.Forms.Button bnOptions;
private System.Windows.Forms.Button bnShare;
private System.Windows.Forms.Button bnTouchpad;
private System.Windows.Forms.Button bnPS;
private System.Windows.Forms.Button bnTouchUpper;
private System.Windows.Forms.Button bnTouchMulti;
private System.Windows.Forms.Button bnLY;
private System.Windows.Forms.ListBox lbControls;
private System.Windows.Forms.Button bnLY2;
private System.Windows.Forms.Button bnRY;
private System.Windows.Forms.Button bnRY2;
private System.Windows.Forms.Button bnLX;
private System.Windows.Forms.Button bnLX2;
private System.Windows.Forms.Button bnRX;
private System.Windows.Forms.Button bnRX2;
private System.Windows.Forms.Button bnL3;
private System.Windows.Forms.Button bnR3;
private System.Windows.Forms.Label TouchTip;
private System.Windows.Forms.Label ReapTip;
private System.Windows.Forms.Label lbMode;
}
}

View File

@ -1,389 +0,0 @@
using DS4Control;
using DS4Library;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ScpServer
{
public partial class CustomMapping : Form
{
private int device;
private bool handleNextKeyPress = false;
private bool ReapTipShown = false;
private List<ComboBox> comboBoxes = new List<ComboBox>();
private List<Button> buttons = new List<Button>();
private string currentMode;
private Dictionary<string, string> defaults = new Dictionary<string, string>();
private ComboBox lastSelected;
private Button lastSelectedBn;
private Dictionary<DS4Controls, GraphicsPath> pictureBoxZones = new Dictionary<DS4Controls, GraphicsPath>();
private DS4Control.Control rootHub = null;
private System.Windows.Forms.Control mappingControl = null;
List<object> availableButtons = new List<object>();
public CustomMapping(DS4Control.Control rootHub, int deviceNum)
{
InitializeComponent();
currentMode = rootHub.getDS4ControllerMode(deviceNum);
this.rootHub = rootHub;
device = deviceNum;
DS4Color color = Global.loadColor(device);
pictureBox.BackColor = Color.FromArgb(color.red, color.green, color.blue);
foreach (System.Windows.Forms.Control control in this.Controls)
{
if (control is Button)
if (((Button)control).Text != "Save" && ((Button)control).Text != "Load")
{
buttons.Add((Button)control);
availableButtons.Add(control.Text);
// Add defaults
defaults.Add(((Button)control).Name, ((Button)control).Text);
// Add events here (easier for modification/addition)
((Button)control).Enter += new System.EventHandler(this.EnterCommand);
((Button)control).KeyDown += new System.Windows.Forms.KeyEventHandler(this.KeyDownCommand);
//((Button)control).Enter += new System.EventHandler(this.TopofListChanged);
//((Button)control).KeyDown += new System.Windows.Forms.KeyEventHandler(this.TopofListChanged);
((Button)control).KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.KeyPressCommand);
((Button)control).PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDownCommand);
lbControls.SelectedIndexChanged += new System.EventHandler(this.SelectedIndexChangedCommand);
}
}
if (currentMode == "Button Mode")
{
bnTouchpad.Location = new System.Drawing.Point(151, 135);
bnTouchpad.Size = new System.Drawing.Size(64, 52);
bnTouchMulti.Location = new System.Drawing.Point(215, 135);
bnTouchMulti.Size = new System.Drawing.Size(64, 52);
TouchTip.Text = "Touchpad (" + currentMode + "):\n Top: Upper Pad \n Left: Left Side \n Right: Right Side";
lbMode.Text = ("Touchpad is in " + currentMode);
}
else if (currentMode == "Disabled" || currentMode == "Cursor Mode")
{
bnTouchpad.Location = new System.Drawing.Point(151, 161);
bnTouchpad.Size = new System.Drawing.Size(128, 26);
bnTouchMulti.Location = new System.Drawing.Point(151, 135);
bnTouchMulti.Size = new System.Drawing.Size(128, 26);
TouchTip.Text = "Touchpad (" + currentMode + "):\n Controls are saved, \n but change modes \n to use touchpad";
lbMode.Text = ("Touchpad is currently disabled");
}
else
{
bnTouchpad.Location = new System.Drawing.Point(151, 161);
bnTouchpad.Size = new System.Drawing.Size(128, 26);
bnTouchMulti.Location = new System.Drawing.Point(151, 135);
bnTouchMulti.Size = new System.Drawing.Size(128, 26);
TouchTip.Text = "Touchpad (" + currentMode + "):\n Top: Upper Pad \n Middle: Multi-Touch \n Bottom: Single Touch";
lbMode.Text = ("Touchpad is in " + currentMode);
}
availableButtons.Sort();
foreach (string s in availableButtons)
lbControls.Items.Add(s);
Global.loadCustomMapping(Global.getCustomMap(device), buttons.ToArray());
}
private void EnterCommand(object sender, EventArgs e)
{
if (sender is Button)
{
ReapTip.Visible = false;
//Change image to represent button
lastSelectedBn = (Button)sender;
if (((Button)sender).Text != "Save" && ((Button)sender).Text != "Load")
lbControls.Items[0] = ((Button)sender).Text;
lbControls.SetSelected(0, true);
switch (lastSelectedBn.Name)
{
#region Set pictureBox.Image to relevant Properties.Resources image
case "bnL2": pictureBox.Image = Properties.Resources._2;
break;
case "bnL1": pictureBox.Image = Properties.Resources._3;
break;
case "bnR2": pictureBox.Image = Properties.Resources._4;
break;
case "bnR1": pictureBox.Image = Properties.Resources._5;
break;
case "bnUp": pictureBox.Image = Properties.Resources._6;
break;
case "bnLeft": pictureBox.Image = Properties.Resources._7;
break;
case "bnDown": pictureBox.Image = Properties.Resources._8;
break;
case "bnRight": pictureBox.Image = Properties.Resources._9;
break;
case "bnL3": pictureBox.Image = Properties.Resources._10;
break;
case "bnLY": pictureBox.Image = Properties.Resources._29;
break;
case "bnLX": pictureBox.Image = Properties.Resources._27;
break;
case "bnLY2": pictureBox.Image = Properties.Resources._28;
break;
case "bnLX2": pictureBox.Image = Properties.Resources._26;
break;
case "bnR3": pictureBox.Image = Properties.Resources._11;
break;
case "bnRY": pictureBox.Image = Properties.Resources._22;
break;
case "bnRX": pictureBox.Image = Properties.Resources._23;
break;
case "bnRY2": pictureBox.Image = Properties.Resources._24;
break;
case "bnRX2": pictureBox.Image = Properties.Resources._25;
break;
case "bnSquare": pictureBox.Image = Properties.Resources._12;
break;
case "bnCross": pictureBox.Image = Properties.Resources._13;
break;
case "bnCircle": pictureBox.Image = Properties.Resources._14;
break;
case "bnTriangle": pictureBox.Image = Properties.Resources._15;
break;
case "bnOptions": pictureBox.Image = Properties.Resources._16;
break;
case "bnShare": pictureBox.Image = Properties.Resources._17;
break;
case "bnTouchpad":
if (currentMode == "Button Mode")
{
pictureBox.Image = Properties.Resources._30;
}
else
pictureBox.Image = Properties.Resources._18;
break;
case "bnTouchUpper": pictureBox.Image = Properties.Resources._20;
break;
case "bnTouchMulti":
if (currentMode == "Button Mode")
{
pictureBox.Image = Properties.Resources._31;
}
else
pictureBox.Image = Properties.Resources._21;
break;
case "bnPS": pictureBox.Image = Properties.Resources._19;
break;
default: pictureBox.Image = Properties.Resources._1;
break;
#endregion
}
if (lastSelectedBn.ForeColor == Color.Red)
cbRepeat.Checked = true;
else cbRepeat.Checked = false;
if (lastSelectedBn.Font.Bold)
cbScanCode.Checked = true;
else cbScanCode.Checked = false;
}
//Show certain list item as default acation, move to top, and resort list
for (int i = 1; i < lbControls.Items.Count; i++)
if (defaults[((Button)sender).Name] == lbControls.Items[i].ToString())
{
for (int j = lbControls.Items.Count-1; j >= 1; j--) //clear all actions but first two
lbControls.Items.RemoveAt(j);
foreach (string s in availableButtons) //re-add all actions
lbControls.Items.Add(s);
for (int t = 1; t < lbControls.Items.Count; t++)
if (defaults[((Button)sender).Name] == lbControls.Items[t].ToString())
{
lbControls.Items[t] = lbControls.Items[t] + " (default)";
string temp = lbControls.Items[t].ToString();
lbControls.Items.RemoveAt(t);
lbControls.Items.Insert(1, temp);
break;
}
break;
}
if (((Button)sender).Name.Contains("bnLX") || ((Button)sender).Name.Contains("bnLY") || ((Button)sender).Name.Contains("bnRX") || ((Button)sender).Name.Contains("bnRY"))
{
lbControls.Items.Insert(2, "Mouse Right");
lbControls.Items.Insert(2, "Mouse Left");
lbControls.Items.Insert(2, "Mouse Down");
lbControls.Items.Insert(2, "Mouse Up");
}
if (((Button)sender).Name.Contains("Touch"))
TouchTip.Visible = true;
else
{
if (ReapTipShown == false)
{
ReapTip.Visible = true;
ReapTipShown = true;
}
TouchTip.Visible = false;
}
}
private void PreviewKeyDownCommand(object sender, PreviewKeyDownEventArgs e)
{
if (sender is Button)
{
if (e.KeyCode == Keys.Tab)
if (((Button)sender).Text.Length == 0)
{
((Button)sender).Tag = e.KeyValue;
((Button)sender).Text = e.KeyCode.ToString();
handleNextKeyPress = true;
}
}
}
private void KeyDownCommand(object sender, KeyEventArgs e)
{
if (sender is Button)
if (((Button)sender).Text != "Save" && ((Button)sender).Text != "Load")
{
if (((Button)sender).Tag is int)
{
if (e.KeyValue == (int)(((Button)sender).Tag)
&& !((Button)sender).Name.Contains("Touch"))
{
if (((Button)sender).ForeColor == SystemColors.WindowText)
{
((Button)sender).ForeColor = Color.Red;
cbRepeat.Checked = true;
}
else
{
((Button)sender).ForeColor = SystemColors.WindowText;
cbRepeat.Checked = false;
}
return;
}
}
if (((Button)sender).Text.Length != 0)
((Button)sender).Text = string.Empty;
else if (e.KeyCode == Keys.Delete)
{
((Button)sender).Tag = e.KeyValue;
((Button)sender).Text= e.KeyCode.ToString();
//lbControls.Items[0] = e.KeyCode.ToString();
e.Handled = true;
e.SuppressKeyPress = true;
}
if (e.KeyCode != Keys.Delete)
{
((Button)sender).Tag = e.KeyValue;
((Button)sender).Text = e.KeyCode.ToString();
//lbControls.Items[0] = e.KeyCode.ToString();
e.Handled = true;
e.SuppressKeyPress = true;
}
lbControls.Items[0] = ((Button)sender).Text;
}
}
private void KeyPressCommand(object sender, KeyPressEventArgs e)
{
if (handleNextKeyPress)
{
e.Handled = true;
handleNextKeyPress = false;
}
}
private void SelectedIndexChangedCommand(object sender, EventArgs e)
{
if (lastSelectedBn != null)
{
if (lbControls.SelectedIndex > 0)
if (lastSelectedBn.Text != lbControls.Items[lbControls.SelectedIndex].ToString())
{
if (lbControls.Items[lbControls.SelectedIndex].ToString().Contains(" (default)"))
{
lastSelectedBn.Text = lbControls.Items[lbControls.SelectedIndex].ToString().Remove(lbControls.Items[lbControls.SelectedIndex].ToString().Length - 10);
lastSelectedBn.Tag = lbControls.Items[lbControls.SelectedIndex].ToString().Remove(lbControls.Items[lbControls.SelectedIndex].ToString().Length - 10);
}
else
{
lastSelectedBn.Text = lbControls.Items[lbControls.SelectedIndex].ToString();
lastSelectedBn.Tag = lbControls.Items[lbControls.SelectedIndex].ToString();
}
}
if (lbControls.SelectedIndex == 0)
{
if (lastSelectedBn.Text != lbControls.Items[0].ToString())
{
lastSelectedBn.Text = lbControls.Items[0].ToString();
lastSelectedBn.Tag = lbControls.Items[0].ToString();
}
}
}
}
private void cbRepeat_CheckedChanged(object sender, EventArgs e)
{
if (!lastSelectedBn.Name.Contains("Touch") && (lastSelectedBn.Tag is int || lastSelectedBn.Tag is UInt16))
if (cbRepeat.Checked)
lastSelectedBn.ForeColor = Color.Red;
else lastSelectedBn.ForeColor = SystemColors.WindowText;
else
{
cbRepeat.Checked = false;
lastSelectedBn.ForeColor = SystemColors.WindowText;
}
}
private void cbScanCode_CheckedChanged(object sender, EventArgs e)
{
if (lastSelectedBn.Tag is int || lastSelectedBn.Tag is UInt16)
if (cbScanCode.Checked)
lastSelectedBn.Font = new Font(lastSelectedBn.Font, FontStyle.Bold);
else lastSelectedBn.Font = new Font(lastSelectedBn.Font, FontStyle.Regular);
else
{
cbScanCode.Checked = false;
lastSelectedBn.Font = new Font(lastSelectedBn.Font, FontStyle.Regular);
}
}
private void TopofListChanged(object sender, EventArgs e)
{
if (((Button)sender).Text != "Save" && ((Button)sender).Text != "Load")
lbControls.Items[0] = ((Button)sender).Text;
}
private void btnSave_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDg = new SaveFileDialog();
saveFileDg.DefaultExt = "xml";
saveFileDg.Filter = "SCP Custom Map Files (*.xml)|*.xml";
saveFileDg.FileName = "SCP Custom Mapping.xml";
if (saveFileDg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (Global.saveCustomMapping(saveFileDg.FileName, buttons.ToArray()))
{
if (MessageBox.Show("Custom mapping saved. Enable now?",
"Save Successfull", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== System.Windows.Forms.DialogResult.Yes)
{
Global.setCustomMap(device, saveFileDg.FileName);
Global.Save();
Global.loadCustomMapping(device);
}
}
else MessageBox.Show("Custom mapping did not save successfully.",
"Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void btnLoad_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDg = new OpenFileDialog();
openFileDg.CheckFileExists = true;
openFileDg.CheckPathExists = true;
openFileDg.DefaultExt = "xml";
openFileDg.Filter = "SCP Custom Map Files (*.xml)|*.xml";
openFileDg.Multiselect = false;
if (openFileDg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Global.loadCustomMapping(openFileDg.FileName, buttons.ToArray());
Global.setCustomMap(device, openFileDg.FileName);
Global.Save();
}
}
}
}

View File

@ -73,18 +73,18 @@
<DependentUpon>AboutBox.cs</DependentUpon> <DependentUpon>AboutBox.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="AdvancedColorDialog.cs" /> <Compile Include="AdvancedColorDialog.cs" />
<Compile Include="CustomMapping.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CustomMapping.Designer.cs">
<DependentUpon>CustomMapping.cs</DependentUpon>
</Compile>
<Compile Include="Hotkeys.cs"> <Compile Include="Hotkeys.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Hotkeys.Designer.cs"> <Compile Include="Hotkeys.Designer.cs">
<DependentUpon>Hotkeys.cs</DependentUpon> <DependentUpon>Hotkeys.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="KBM360.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="KBM360.Designer.cs">
<DependentUpon>KBM360.cs</DependentUpon>
</Compile>
<Compile Include="Options.cs"> <Compile Include="Options.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -93,6 +93,11 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ScpForm.cs"> <Compile Include="ScpForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -103,25 +108,20 @@
<EmbeddedResource Include="AboutBox.resx"> <EmbeddedResource Include="AboutBox.resx">
<DependentUpon>AboutBox.cs</DependentUpon> <DependentUpon>AboutBox.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="CustomMapping.resx">
<DependentUpon>CustomMapping.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Hotkeys.resx"> <EmbeddedResource Include="Hotkeys.resx">
<DependentUpon>Hotkeys.cs</DependentUpon> <DependentUpon>Hotkeys.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="KBM360.resx">
<DependentUpon>KBM360.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options.resx"> <EmbeddedResource Include="Options.resx">
<DependentUpon>Options.cs</DependentUpon> <DependentUpon>Options.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator> <Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType> <SubType>Designer</SubType>
<LastGenOutput>Resources1.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="ScpForm.resx"> <EmbeddedResource Include="ScpForm.resx">
<DependentUpon>ScpForm.cs</DependentUpon> <DependentUpon>ScpForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
@ -146,38 +146,12 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Resources\1.png" /> <None Include="Resources\Touch states2.png" />
<Content Include="Resources\10.png" /> <None Include="Resources\sticks2.png" />
<Content Include="Resources\11.png" /> <None Include="Resources\360 fades.png" />
<Content Include="Resources\12.png" /> <None Include="Resources\DS4 Controller.png" />
<Content Include="Resources\13.png" />
<Content Include="Resources\14.png" />
<Content Include="Resources\15.png" />
<Content Include="Resources\16.png" />
<Content Include="Resources\17.png" />
<Content Include="Resources\18.png" />
<Content Include="Resources\19.png" />
<Content Include="Resources\2.png" />
<Content Include="Resources\20.png" />
<Content Include="Resources\21.png" />
<Content Include="Resources\22.png" />
<Content Include="Resources\23.png" />
<None Include="Resources\24.png" />
<None Include="Resources\25.png" />
<None Include="Resources\26.png" />
<None Include="Resources\27.png" />
<None Include="Resources\28.png" />
<None Include="Resources\29.png" />
<Content Include="Resources\3.png" />
<None Include="Resources\30.png" />
<None Include="Resources\31.png" />
<Content Include="Resources\4.png" />
<Content Include="Resources\5.png" />
<Content Include="Resources\6.png" />
<Content Include="Resources\7.png" />
<Content Include="Resources\8.png" />
<Content Include="Resources\9.png" />
<Content Include="Resources\DS4.ico" /> <Content Include="Resources\DS4.ico" />
<None Include="Resources\mouse.png" />
<Content Include="Resources\Scp_All.ico" /> <Content Include="Resources\Scp_All.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -29,17 +29,14 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.label9 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label(); this.label14 = new System.Windows.Forms.Label();
@ -51,27 +48,18 @@
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(22, 17); this.label1.Location = new System.Drawing.Point(22, 17);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(151, 13); this.label1.Size = new System.Drawing.Size(129, 13);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "Finger on Touchpad + Options"; this.label1.Text = "Finger on Touchpad + PS";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(22, 44);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(143, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Finger on Touchpad + Share";
// //
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(22, 97); this.label3.Location = new System.Drawing.Point(22, 97);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(51, 13); this.label3.Size = new System.Drawing.Size(108, 13);
this.label3.TabIndex = 2; this.label3.TabIndex = 2;
this.label3.Text = "Pad click"; this.label3.Text = "Pad click (if tap is on)";
// //
// label4 // label4
// //
@ -87,36 +75,27 @@
this.label5.AutoSize = true; this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(222, 17); this.label5.Location = new System.Drawing.Point(222, 17);
this.label5.Name = "label5"; this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(106, 13); this.label5.Size = new System.Drawing.Size(138, 26);
this.label5.TabIndex = 4; this.label5.TabIndex = 4;
this.label5.Text = "Next touchpad mode"; this.label5.Text = "Turn off touchpad movment\r\n(pressing still works)";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(222, 44);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(125, 13);
this.label6.TabIndex = 5;
this.label6.Text = "Previous touchpad mode";
// //
// label7 // label7
// //
this.label7.AutoSize = true; this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(222, 97); this.label7.Location = new System.Drawing.Point(222, 97);
this.label7.Name = "label7"; this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(156, 13); this.label7.Size = new System.Drawing.Size(50, 13);
this.label7.TabIndex = 6; this.label7.TabIndex = 6;
this.label7.Text = "Left click (while touchpad is on)"; this.label7.Text = "Left click";
// //
// label8 // label8
// //
this.label8.AutoSize = true; this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(222, 122); this.label8.Location = new System.Drawing.Point(222, 122);
this.label8.Name = "label8"; this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(163, 13); this.label8.Size = new System.Drawing.Size(145, 26);
this.label8.TabIndex = 7; this.label8.TabIndex = 7;
this.label8.Text = "Right click (while touchpad is on)"; this.label8.Text = "Right click (Best used with \r\nright side is used as a mouse)";
// //
// button1 // button1
// //
@ -146,15 +125,6 @@
this.label10.TabIndex = 9; this.label10.TabIndex = 9;
this.label10.Text = "Two fingers up/down on touchpad"; this.label10.Text = "Two fingers up/down on touchpad";
// //
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(23, 108);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(92, 13);
this.label12.TabIndex = 12;
this.label12.Text = "and tap if enabled";
//
// label11 // label11
// //
this.label11.AutoSize = true; this.label11.AutoSize = true;
@ -176,7 +146,7 @@
// label14 // label14
// //
this.label14.AutoSize = true; this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(222, 145); this.label14.Location = new System.Drawing.Point(223, 49);
this.label14.Name = "label14"; this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(131, 13); this.label14.Size = new System.Drawing.Size(131, 13);
this.label14.TabIndex = 16; this.label14.TabIndex = 16;
@ -185,7 +155,7 @@
// label15 // label15
// //
this.label15.AutoSize = true; this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(22, 145); this.label15.Location = new System.Drawing.Point(23, 49);
this.label15.Name = "label15"; this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(103, 13); this.label15.Size = new System.Drawing.Size(103, 13);
this.label15.TabIndex = 15; this.label15.TabIndex = 15;
@ -205,13 +175,10 @@
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
this.Controls.Add(this.label8); this.Controls.Add(this.label8);
this.Controls.Add(this.label7); this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5); this.Controls.Add(this.label5);
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.label12);
this.Name = "Hotkeys"; this.Name = "Hotkeys";
this.Text = "Hotkeys"; this.Text = "Hotkeys";
this.ResumeLayout(false); this.ResumeLayout(false);
@ -222,17 +189,14 @@
#endregion #endregion
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10; private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label11; private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label13; private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label14; private System.Windows.Forms.Label label14;

2020
DS4Tool/KBM360.Designer.cs generated Normal file

File diff suppressed because it is too large Load Diff

100
DS4Tool/KBM360.cs Normal file
View File

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ScpServer
{
public partial class KBM360 : Form
{
private DS4Control.Control scpDevice;
private int device;
private Button button;
private Options ops;
public KBM360(DS4Control.Control bus_device, int deviceNum, Options ooo, Button buton, int tabStart)
{
InitializeComponent();
device = deviceNum;
scpDevice = bus_device;
ops = ooo;
button = buton;
if (button.ForeColor == Color.Red)
cbRepeat.Checked = true;
if (button.Font.Bold)
cbScanCode.Checked = true;
Text = "Select an action for " + button.Name.Substring(2);
foreach (System.Windows.Forms.Control control in tabKBM.Controls)
if (control is Button)
((Button)control).Click += new System.EventHandler(anybtn_Click);
foreach (System.Windows.Forms.Control control in tab360.Controls)
if (control is Button)
((Button)control).Click += new System.EventHandler(anybtn_Click360);
if (tabStart < 2)
tabControl1.SelectedIndex = tabStart;
else
tabControl1.SelectedIndex = 0;
ReFocus();
}
public void anybtn_Click(object sender, EventArgs e)
{
if (sender is Button)
{
string keyname;
if (((Button)sender).Text.Contains('↑') || ((Button)sender).Text.Contains('↓') || ((Button)sender).Text.Contains('→') || ((Button)sender).Text.Contains('↑'))
keyname = ((Button)sender).Text.Substring(1);
else if (((Button)sender).Font.Name == "Webdings")
{
if (((Button)sender).Text == "9")
keyname = "Previous Track";
else if (((Button)sender).Text == "<")
keyname = "Stop Track";
else if (((Button)sender).Text == "4")
keyname = "Play/Pause";
else if (((Button)sender).Text == ":")
keyname = "Next Track";
else
keyname = "How did you get here?";
}
else
keyname = ((Button)sender).Text;
object keytag = ((Button)sender).Tag;
ops.ChangeButtonText(keyname, keytag);
this.Close();
}
}
private void ReFocus()
{
if (ops.Focused)
this.Enabled = false;
}
public void anybtn_Click360(object sender, EventArgs e)
{
if (sender is Button)
{
string keyname = ((Button)sender).Text;
ops.ChangeButtonText(keyname);
this.Close();
}
}
private void finalMeasure(object sender, FormClosedEventArgs e)
{
ops.Toggle_Repeat(cbRepeat.Checked);
ops.Toggle_ScanCode(cbScanCode.Checked);
ops.UpdateLists();
}
private void Key_Down_Action(object sender, KeyEventArgs e)
{
ops.ChangeButtonText(e.KeyCode.ToString(), e.KeyValue);
this.Close();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,55 +3,98 @@ using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using DS4Library; using DS4Library;
using DS4Control; using DS4Control;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
namespace ScpServer namespace ScpServer
{ {
public partial class Options : Form public partial class Options : Form
{ {
private DS4Control.Control scpDevice; private DS4Control.Control scpDevice;
private int device; private int device;
private string filename;
private ScpForm mainWin;
Byte[] oldLedColor, oldLowLedColor; Byte[] oldLedColor, oldLowLedColor;
TrackBar tBsixaxisGyroX, tBsixaxisGyroY, tBsixaxisGyroZ, TrackBar tBsixaxisGyroX, tBsixaxisGyroY, tBsixaxisGyroZ,
tBsixaxisAccelX, tBsixaxisAccelY, tBsixaxisAccelZ; tBsixaxisAccelX, tBsixaxisAccelY, tBsixaxisAccelZ;
Timer sixaxisTimer = new Timer(); Timer sixaxisTimer = new Timer();
private List<Button> buttons = new List<Button>();
//private Dictionary<string, string> defaults = new Dictionary<string, string>();
private Button lastSelected;
int alphacolor;
Color reg;
Color full;
public Options(DS4Control.Control bus_device, int deviceNum) public Options(DS4Control.Control bus_device, int deviceNum, string name, ScpForm mainWindow)
{ {
InitializeComponent(); InitializeComponent();
device = deviceNum; device = deviceNum;
scpDevice = bus_device; scpDevice = bus_device;
DS4Color color = Global.loadColor(device); filename = name;
redBar.Value = color.red; mainWin = mainWindow;
greenBar.Value = color.green; if (filename != "" && filename != "+New Profile")
blueBar.Value = color.blue; {
rumbleBoostBar.Value = DS4Control.Global.loadRumbleBoost(device); tBProfile.Text = filename;
batteryLed.Checked = DS4Control.Global.getLedAsBatteryIndicator(device); DS4Color color = Global.loadColor(device);
flashLed.Checked = DS4Control.Global.getFlashWhenLowBattery(device); redBar.Value = color.red;
touchCheckBox.Checked = Global.getTouchEnabled(device); greenBar.Value = color.green;
touchSensitivityBar.Value = Global.getTouchSensitivity(device); blueBar.Value = color.blue;
leftTriggerMiddlePoint.Text = Global.getLeftTriggerMiddle(device).ToString(); rumbleBoostBar.Value = DS4Control.Global.loadRumbleBoost(device);
rightTriggerMiddlePoint.Text = Global.getRightTriggerMiddle(device).ToString(); rumbleSwap.Checked = Global.getRumbleSwap(device);
DS4Color lowColor = Global.loadLowColor(device); batteryLed.Checked = DS4Control.Global.getLedAsBatteryIndicator(device);
touchpadJitterCompensation.Checked = Global.getTouchpadJitterCompensation(device); flashLed.Checked = DS4Control.Global.getFlashWhenLowBattery(device);
lowerRCOffCheckBox.Checked = Global.getLowerRCOff(device); numUDTouch.Value = Global.getTouchSensitivity(device);
tapSensitivityBar.Value = Global.getTapSensitivity(device); numUDScroll.Value = Global.getScrollSensitivity(device);
scrollSensitivityBar.Value = Global.getScrollSensitivity(device); numUDTap.Value = Global.getTapSensitivity(device);
flushHIDQueue.Checked = Global.getFlushHIDQueue(device); cBTap.Checked = Global.getTap(device);
advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor; leftTriggerMiddlePoint.Text = Global.getLeftTriggerMiddle(device).ToString();
rightTriggerMiddlePoint.Text = Global.getRightTriggerMiddle(device).ToString();
// Force update of color choosers DS4Color lowColor = Global.loadLowColor(device);
colorChooserButton.BackColor = Color.FromArgb(color.red, color.green, color.blue); touchpadJitterCompensation.Checked = Global.getTouchpadJitterCompensation(device);
lowColorChooserButton.BackColor = Color.FromArgb(lowColor.red, lowColor.green, lowColor.blue); cBlowerRCOn.Checked = Global.getLowerRCOn(device);
pictureBox.BackColor = colorChooserButton.BackColor; flushHIDQueue.Checked = Global.getFlushHIDQueue(device);
lowRedValLabel.Text = lowColor.red.ToString(); idleDisconnectTimeout.Value = Global.getIdleDisconnectTimeout(device);
lowGreenValLabel.Text = lowColor.green.ToString(); // Force update of color choosers
lowBlueValLabel.Text = lowColor.blue.ToString(); alphacolor = Math.Max(redBar.Value, Math.Max(greenBar.Value, blueBar.Value));
reg = Color.FromArgb(color.red, color.green, color.blue);
full = HuetoRGB(reg.GetHue(), reg.GetSaturation());
colorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full);
pBController.BackColor = colorChooserButton.BackColor;
lowColorChooserButton.BackColor = Color.FromArgb(lowColor.red, lowColor.green, lowColor.blue);
lowRedValLabel.Text = lowColor.red.ToString();
lowGreenValLabel.Text = lowColor.green.ToString();
lowBlueValLabel.Text = lowColor.blue.ToString();
}
else
{
Global.saveColor(device,
(byte)redBar.Value,
(byte)greenBar.Value,
(byte)blueBar.Value);
Global.saveLowColor(device,
(byte)redBar.Value,
(byte)greenBar.Value,
(byte)blueBar.Value);
double middle;
if (Double.TryParse(leftTriggerMiddlePoint.Text, out middle))
Global.setLeftTriggerMiddle(device, middle);
if (Double.TryParse(rightTriggerMiddlePoint.Text, out middle))
Global.setRightTriggerMiddle(device, middle);
Global.saveRumbleBoost(device, (byte)rumbleBoostBar.Value);
scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value, device);
Global.setRumbleSwap(device, rumbleSwap.Checked);
Global.setTouchSensitivity(device, (byte)numUDTouch.Value);
Global.setTouchpadJitterCompensation(device, touchpadJitterCompensation.Checked);
Global.setLowerRCOn(device, cBlowerRCOn.Checked);
Global.setTapSensitivity(device, (byte)numUDTap.Value);
Global.setScrollSensitivity(device, (byte)numUDScroll.Value);
Global.setIdleDisconnectTimeout(device, (int)idleDisconnectTimeout.Value);
}
#region watch sixaxis data #region watch sixaxis data
// Control Positioning // Control Positioning
int horizontalOffset = cbSixaxis.Location.X - 50, int horizontalOffset = cbSixaxis.Location.X,
verticalOffset = cbSixaxis.Location.Y + cbSixaxis.Height + 5, verticalOffset = cbSixaxis.Location.Y + cbSixaxis.Height + 5,
tWidth = 100, tHeight = 19, tWidth = 100, tHeight = 19,
horizontalMargin = 10 + tWidth, horizontalMargin = 10 + tWidth,
verticalMargin = 1 + tHeight; verticalMargin = 1 + tHeight;
@ -100,7 +143,7 @@ namespace ScpServer
tBsixaxisAccelZ.Name = "tBsixaxisAccelZ"; tBsixaxisAccelZ.Name = "tBsixaxisAccelZ";
foreach (TrackBar t in allSixAxes) foreach (TrackBar t in allSixAxes)
{ {
tabTuning.Controls.Add(t); tabOther.Controls.Add(t);
((System.ComponentModel.ISupportInitialize)(t)).EndInit(); ((System.ComponentModel.ISupportInitialize)(t)).EndInit();
} }
} }
@ -119,10 +162,38 @@ namespace ScpServer
} }
}); });
sixaxisTimer.Interval = 1000 / 60; sixaxisTimer.Interval = 1000 / 60;
this.FormClosing += delegate { if (sixaxisTimer.Enabled) sixaxisTimer.Stop(); }; this.FormClosing += delegate
{
if (sixaxisTimer.Enabled)
sixaxisTimer.Stop();
//foreach (CustomMapping cmf in customMappingForms)
// if (cmf != null)
// cmf.Close();
};
if (cbSixaxis.Checked) if (cbSixaxis.Checked)
sixaxisTimer.Start(); sixaxisTimer.Start();
#endregion #endregion
foreach (System.Windows.Forms.Control control in tabControls.Controls)
if (control is Button)
if (!((Button)control).Text.Contains("btn"))
buttons.Add((Button)control);
foreach (System.Windows.Forms.Control control in tabTouchPad.Controls)
if (control is Button)
buttons.Add((Button)control);
foreach (System.Windows.Forms.Control control in tabAnalogSticks.Controls)
if (control is Button)
buttons.Add((Button)control);
if (filename != "" && filename != "New Profile")
Global.LoadProfile(device, buttons.ToArray());
ToolTip tp = new ToolTip();
tp.SetToolTip(cBlowerRCOn, "Best used with right side as mouse");
advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor;
btnLeftStick.Enter += btnSticks_Enter;
btnRightStick.Enter += btnSticks_Enter;
btnTouchtab.Enter += btnTouchtab_Enter;
btnLightbar.Click += btnLightbar_Click;
UpdateLists();
} }
private void cbSixaxis_CheckedChanged(object sender, EventArgs e) private void cbSixaxis_CheckedChanged(object sender, EventArgs e)
@ -161,43 +232,119 @@ namespace ScpServer
trackBar.Value = value; trackBar.Value = value;
} }
private void CustomMappingButton_Click(object sender, EventArgs e) KBM360 kbm360 = null;
private void Show_ControlsBn(object sender, EventArgs e)
{ {
// open a custom mapping form lastSelected = (Button)sender;
CustomMapping cmForm = new CustomMapping(scpDevice, device); kbm360 = new KBM360(scpDevice, device, this, lastSelected, 0);
cmForm.Icon = this.Icon; kbm360.Icon = this.Icon;
cmForm.Show(); kbm360.ShowDialog();
//kbm360.FormClosed += delegate { kbm360 = null; };
//this.Enabled = false;
} }
private void setButton_Click(object sender, EventArgs e) private void Show360Controls(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
lastSelected = (Button)sender;
kbm360 = new KBM360(scpDevice, device, this, lastSelected, 1);
kbm360.Icon = this.Icon;
kbm360.ShowDialog();
}
}
public void ChangeButtonText(string controlname, object tag)
{
lastSelected.Text = controlname;
int value;
if (Int32.TryParse(tag.ToString(), out value))
lastSelected.Tag = value;
else
lastSelected.Tag = tag.ToString();
}
public void ChangeButtonText(string controlname)
{
lastSelected.Text = controlname;
lastSelected.Tag = controlname;
}
public void Toggle_Repeat(bool Checked)
{
if (lastSelected.Tag is int || lastSelected.Tag is UInt16)
if (Checked)
lastSelected.ForeColor = Color.Red;
else lastSelected.ForeColor = SystemColors.WindowText;
else
{
//cbRepeat.Checked = false;
lastSelected.ForeColor = SystemColors.WindowText;
}
}
public void Toggle_ScanCode(bool Checked)
{
if (lastSelected.Tag is int || lastSelected.Tag is UInt16)
if (Checked)
lastSelected.Font = new Font(lastSelected.Font, FontStyle.Bold);
else lastSelected.Font = new Font(lastSelected.Font, FontStyle.Regular);
else
{
//cbScanCode.Checked = false;
lastSelected.Font = new Font(lastSelected.Font, FontStyle.Regular);
}
}
private void btnSticks_Enter(object sender, EventArgs e)
{
tabOptions.SelectTab(1);
}
private void btnTouchtab_Enter(object sender, EventArgs e)
{
tabOptions.SelectTab(2);
}
private void btnLightbar_Click(object sender, EventArgs e)
{
//tabOptions.SelectTab(3);
if (lowLedCheckBox.Checked)
lowColorChooserButton_Click(sender, e);
else colorChooserButton_Click(sender, e);
}
private void saveButton_Click(object sender, EventArgs e)
{ {
Global.saveColor(device, Global.saveColor(device,
colorChooserButton.BackColor.R, (byte)redBar.Value,
colorChooserButton.BackColor.G, (byte)greenBar.Value,
colorChooserButton.BackColor.B); (byte)blueBar.Value);
Global.saveLowColor(device, Global.saveLowColor(device,
lowColorChooserButton.BackColor.R, lowColorChooserButton.BackColor.R,
lowColorChooserButton.BackColor.G, lowColorChooserButton.BackColor.G,
lowColorChooserButton.BackColor.B); lowColorChooserButton.BackColor.B);
double middle; double middle;
if (Double.TryParse(leftTriggerMiddlePoint.Text, out middle)) if (Double.TryParse(leftTriggerMiddlePoint.Text, out middle))
Global.setLeftTriggerMiddle(device, middle); Global.setLeftTriggerMiddle(device, middle);
if (Double.TryParse(rightTriggerMiddlePoint.Text, out middle)) if (Double.TryParse(rightTriggerMiddlePoint.Text, out middle))
Global.setRightTriggerMiddle(device, middle); Global.setRightTriggerMiddle(device, middle);
Global.saveRumbleBoost(device,(byte)rumbleBoostBar.Value); Global.saveRumbleBoost(device, (byte)rumbleBoostBar.Value);
scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value,device); scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value, device);
Global.setTouchSensitivity(device, (byte)touchSensitivityBar.Value); Global.setRumbleSwap(device, rumbleSwap.Checked);
Global.setTouchSensitivity(device, (byte)numUDTouch.Value);
Global.setTouchpadJitterCompensation(device, touchpadJitterCompensation.Checked); Global.setTouchpadJitterCompensation(device, touchpadJitterCompensation.Checked);
Global.setLowerRCOff(device, !lowerRCOffCheckBox.Checked); Global.setLowerRCOn(device, cBlowerRCOn.Checked);
Global.setTapSensitivity(device, (byte)tapSensitivityBar.Value); Global.setScrollSensitivity(device, (byte)numUDScroll.Value);
Global.setScrollSensitivity(device, scrollSensitivityBar.Value); int disconnectTimeout;
} if (int.TryParse(idleDisconnectTimeout.Text, out disconnectTimeout))
Global.setIdleDisconnectTimeout(device, disconnectTimeout);
if (tBProfile.Text != null && tBProfile.Text != "" && !tBProfile.Text.Contains("\\") && !tBProfile.Text.Contains("/") && !tBProfile.Text.Contains(":") && !tBProfile.Text.Contains("*") && !tBProfile.Text.Contains("?") && !tBProfile.Text.Contains("\"") && !tBProfile.Text.Contains("<") && !tBProfile.Text.Contains(">") && !tBProfile.Text.Contains("|"))
{
Global.setAProfile(device, tBProfile.Text);
Global.SaveProfile(tBProfile.Text, buttons.ToArray());
Global.Save();
this.Close();
}
else
MessageBox.Show("Please enter a valid name", "Not valid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
private void saveButton_Click(object sender, EventArgs e)
{
setButton_Click(null, null);
Global.Save();
this.Close();
} }
private void redBar_ValueChanged(object sender, EventArgs e) private void redBar_ValueChanged(object sender, EventArgs e)
@ -205,37 +352,24 @@ namespace ScpServer
// New settings // New settings
if (lowLedCheckBox.Checked) if (lowLedCheckBox.Checked)
{ {
lowRedValLabel.Text = redBar.Value.ToString(); //lowRedValLabel.Text = redBar.Value.ToString();
lowColorChooserButton.BackColor = Color.FromArgb( lowColorChooserButton.BackColor = Color.FromArgb(
redBar.Value, redBar.Value,
lowColorChooserButton.BackColor.G, lowColorChooserButton.BackColor.G,
lowColorChooserButton.BackColor.B); lowColorChooserButton.BackColor.B);
pictureBox.BackColor = Color.FromArgb( Global.saveLowColor(device, (byte)redBar.Value, lowColorChooserButton.BackColor.G, lowColorChooserButton.BackColor.B);
redBar.Value,
lowColorChooserButton.BackColor.G,
lowColorChooserButton.BackColor.B);
if (realTimeChangesCheckBox.Checked)
Global.saveLowColor(device, (byte)redBar.Value,
lowColorChooserButton.BackColor.G,
lowColorChooserButton.BackColor.B);
} }
else else
{ {
colorChooserButton.BackColor = Color.FromArgb( alphacolor = Math.Max(redBar.Value, Math.Max(greenBar.Value, blueBar.Value));
redBar.Value, reg = Color.FromArgb(redBar.Value, greenBar.Value, blueBar.Value);
colorChooserButton.BackColor.G, full = HuetoRGB(reg.GetHue(), reg.GetSaturation());
colorChooserButton.BackColor.B); colorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor +50)), full);
pictureBox.BackColor = Color.FromArgb( Global.saveColor(device, (byte)redBar.Value, (byte)greenBar.Value, (byte)blueBar.Value);
redBar.Value, pBController.BackColor = colorChooserButton.BackColor;
colorChooserButton.BackColor.G,
colorChooserButton.BackColor.B);
if (realTimeChangesCheckBox.Checked)
Global.saveColor(device, (byte)redBar.Value,
colorChooserButton.BackColor.G,
colorChooserButton.BackColor.B);
// Previous implementation // Previous implementation
redValLabel.Text = redBar.Value.ToString(); redValLabel.Text = redBar.Value.ToString();
//redValLabel.Text = (colorChooserButton.BackColor.GetBrightness() * 255 * 2).ToString();
} }
} }
private void greenBar_ValueChanged(object sender, EventArgs e) private void greenBar_ValueChanged(object sender, EventArgs e)
@ -248,32 +382,17 @@ namespace ScpServer
lowColorChooserButton.BackColor.R, lowColorChooserButton.BackColor.R,
greenBar.Value, greenBar.Value,
lowColorChooserButton.BackColor.B); lowColorChooserButton.BackColor.B);
pictureBox.BackColor = Color.FromArgb( Global.saveLowColor(device, lowColorChooserButton.BackColor.R, (byte)greenBar.Value, lowColorChooserButton.BackColor.B);
lowColorChooserButton.BackColor.R,
greenBar.Value,
lowColorChooserButton.BackColor.B);
if (realTimeChangesCheckBox.Checked)
Global.saveLowColor(device,
lowColorChooserButton.BackColor.R,
(byte)greenBar.Value,
lowColorChooserButton.BackColor.B);
} }
else else
{ {
colorChooserButton.BackColor = Color.FromArgb( alphacolor = Math.Max(redBar.Value, Math.Max(greenBar.Value, blueBar.Value));
colorChooserButton.BackColor.R, reg = Color.FromArgb(redBar.Value, greenBar.Value, blueBar.Value);
greenBar.Value, full = HuetoRGB(reg.GetHue(), reg.GetSaturation());
colorChooserButton.BackColor.B); colorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full);
pictureBox.BackColor = Color.FromArgb( Global.saveColor(device, (byte)redBar.Value, (byte)greenBar.Value, (byte)blueBar.Value);
colorChooserButton.BackColor.R,
greenBar.Value,
colorChooserButton.BackColor.B);
if (realTimeChangesCheckBox.Checked)
Global.saveColor(device,
colorChooserButton.BackColor.R,
(byte)greenBar.Value,
colorChooserButton.BackColor.B);
pBController.BackColor = colorChooserButton.BackColor;
// Previous implementation // Previous implementation
greenValLabel.Text = greenBar.Value.ToString(); greenValLabel.Text = greenBar.Value.ToString();
} }
@ -288,90 +407,84 @@ namespace ScpServer
lowColorChooserButton.BackColor.R, lowColorChooserButton.BackColor.R,
lowColorChooserButton.BackColor.G, lowColorChooserButton.BackColor.G,
blueBar.Value); blueBar.Value);
pictureBox.BackColor = Color.FromArgb( //if (realTimeChangesCheckBox.Checked)
Global.saveLowColor(device,
lowColorChooserButton.BackColor.R, lowColorChooserButton.BackColor.R,
lowColorChooserButton.BackColor.G, lowColorChooserButton.BackColor.G,
blueBar.Value); (byte)blueBar.Value);
if (realTimeChangesCheckBox.Checked)
Global.saveLowColor(device,
lowColorChooserButton.BackColor.R,
lowColorChooserButton.BackColor.G,
(byte)blueBar.Value);
} }
else else
{ {
colorChooserButton.BackColor = Color.FromArgb( alphacolor = Math.Max(redBar.Value, Math.Max(greenBar.Value, blueBar.Value));
colorChooserButton.BackColor.R, reg = Color.FromArgb(redBar.Value, greenBar.Value, blueBar.Value);
colorChooserButton.BackColor.G, full = HuetoRGB(reg.GetHue(), reg.GetSaturation());
blueBar.Value); colorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full);
pictureBox.BackColor = Color.FromArgb( //if (realTimeChangesCheckBox.Checked)
colorChooserButton.BackColor.R, Global.saveColor(device, (byte)redBar.Value,
colorChooserButton.BackColor.G, (byte)greenBar.Value,
blueBar.Value); (byte)blueBar.Value);
if (realTimeChangesCheckBox.Checked)
Global.saveColor(device,
colorChooserButton.BackColor.R,
colorChooserButton.BackColor.G,
(byte)blueBar.Value);
pBController.BackColor = colorChooserButton.BackColor;
// Previous implementation // Previous implementation
blueValLabel.Text = blueBar.Value.ToString(); blueValLabel.Text = blueBar.Value.ToString();
} }
} }
public Color HuetoRGB(float hue, float sat)
{
int C = (int)(sat*255);
int X = (int)((sat * (float)(1 - Math.Abs((hue / 60) % 2 - 1)))*255);
if (sat == 0)
return Color.FromName("White");
else if (0 <= hue && hue < 60)
return Color.FromArgb(C, X, 0);
else if (60 <= hue && hue < 120)
return Color.FromArgb(X, C, 0);
else if (120 <= hue && hue < 180)
return Color.FromArgb(0, C, X);
else if (180 <= hue && hue < 240)
return Color.FromArgb(0, X, C);
else if (240 <= hue && hue < 300)
return Color.FromArgb(X, 0, C);
else if (300 <= hue && hue < 360)
return Color.FromArgb(C, 0, X);
else
return Color.FromName("Black");
}
private void rumbleBoostBar_ValueChanged(object sender, EventArgs e) private void rumbleBoostBar_ValueChanged(object sender, EventArgs e)
{ {
rumbleBoostMotorValLabel.Text = rumbleBoostBar.Value.ToString(); rumbleBoostMotorValLabel.Text = rumbleBoostBar.Value.ToString();
Global.saveRumbleBoost(device, (byte)rumbleBoostBar.Value);
scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value, device);
if (realTimeChangesCheckBox.Checked)
{
Global.saveRumbleBoost(device, (byte)rumbleBoostBar.Value);
scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value, device);
}
} }
private void leftMotorBar_ValueChanged(object sender, EventArgs e) private void leftMotorBar_ValueChanged(object sender, EventArgs e)
{ {
leftMotorValLabel.Text = leftMotorBar.Value.ToString(); leftMotorValLabel.Text = leftMotorBar.Value.ToString();
scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value, device);
if (realTimeChangesCheckBox.Checked)
scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value, device);
} }
private void rightMotorBar_ValueChanged(object sender, EventArgs e) private void rightMotorBar_ValueChanged(object sender, EventArgs e)
{ {
rightMotorValLabel.Text = rightMotorBar.Value.ToString(); rightMotorValLabel.Text = rightMotorBar.Value.ToString();
scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value, device);
if (realTimeChangesCheckBox.Checked)
scpDevice.setRumble((byte)leftMotorBar.Value, (byte)rightMotorBar.Value, device);
} }
private void touchSensitivityBar_ValueChanged(object sender, EventArgs e) private void numUDTouch_ValueChanged(object sender, EventArgs e)
{ {
sensitivityValLabel.Text = touchSensitivityBar.Value.ToString(); Global.setTouchSensitivity(device, (byte)numUDTouch.Value);
if (realTimeChangesCheckBox.Checked)
Global.setTouchSensitivity(device, (byte)touchSensitivityBar.Value);
} }
private void tapSensitivityBar_ValueChanged(object sender, EventArgs e)
{
tapSensitivityValLabel.Text = tapSensitivityBar.Value.ToString();
if (tapSensitivityValLabel.Text == "0")
tapSensitivityValLabel.Text = "Off";
if (realTimeChangesCheckBox.Checked) private void numUDTap_ValueChanged(object sender, EventArgs e)
Global.setTapSensitivity(device, (byte)tapSensitivityBar.Value); {
Global.setTapSensitivity(device, (byte)numUDTap.Value);
} }
private void scrollSensitivityBar_ValueChanged(object sender, EventArgs e)
{
scrollSensitivityValLabel.Text = scrollSensitivityBar.Value.ToString();
if (scrollSensitivityValLabel.Text == "0")
scrollSensitivityValLabel.Text = "Off";
if (realTimeChangesCheckBox.Checked) private void numUDScroll_ValueChanged(object sender, EventArgs e)
Global.setScrollSensitivity(device, (byte)scrollSensitivityBar.Value); {
Global.setScrollSensitivity(device, (byte)numUDScroll.Value);
} }
private void lowBatteryLed_CheckedChanged(object sender, EventArgs e) private void lowBatteryLed_CheckedChanged(object sender, EventArgs e)
@ -382,12 +495,11 @@ namespace ScpServer
redBar.Value = int.Parse(lowRedValLabel.Text); redBar.Value = int.Parse(lowRedValLabel.Text);
greenBar.Value = int.Parse(lowGreenValLabel.Text); greenBar.Value = int.Parse(lowGreenValLabel.Text);
blueBar.Value = int.Parse(lowBlueValLabel.Text); blueBar.Value = int.Parse(lowBlueValLabel.Text);
pictureBox.BackColor = lowColorChooserButton.BackColor;
if (realTimeChangesCheckBox.Checked) Global.saveLowColor(device,
Global.saveLowColor(device, lowColorChooserButton.BackColor.R,
lowColorChooserButton.BackColor.R, lowColorChooserButton.BackColor.G,
lowColorChooserButton.BackColor.G, lowColorChooserButton.BackColor.B);
lowColorChooserButton.BackColor.B);
} }
else else
{ {
@ -395,12 +507,11 @@ namespace ScpServer
redBar.Value = int.Parse(redValLabel.Text); redBar.Value = int.Parse(redValLabel.Text);
greenBar.Value = int.Parse(greenValLabel.Text); greenBar.Value = int.Parse(greenValLabel.Text);
blueBar.Value = int.Parse(blueValLabel.Text); blueBar.Value = int.Parse(blueValLabel.Text);
pictureBox.BackColor = colorChooserButton.BackColor;
if (realTimeChangesCheckBox.Checked) Global.saveColor(device,
Global.saveColor(device, colorChooserButton.BackColor.R,
colorChooserButton.BackColor.R, colorChooserButton.BackColor.G,
colorChooserButton.BackColor.G, colorChooserButton.BackColor.B);
colorChooserButton.BackColor.B);
} }
} }
private void ledAsBatteryIndicator_CheckedChanged(object sender, EventArgs e) private void ledAsBatteryIndicator_CheckedChanged(object sender, EventArgs e)
@ -412,48 +523,32 @@ namespace ScpServer
{ {
lowLedPanel.Visible = true; lowLedPanel.Visible = true;
lowLedCheckBox.Visible = true; lowLedCheckBox.Visible = true;
if (realTimeChangesCheckBox.Checked)
Global.setLedAsBatteryIndicator(device, true); Global.setLedAsBatteryIndicator(device, true);
} }
else else
{ {
lowLedPanel.Visible = false; lowLedPanel.Visible = false;
lowLedCheckBox.Visible = false; lowLedCheckBox.Visible = false;
if (realTimeChangesCheckBox.Checked)
Global.setLedAsBatteryIndicator(device, false); Global.setLedAsBatteryIndicator(device, false);
} }
} }
private void flashWhenLowBattery_CheckedChanged(object sender, EventArgs e) private void flashWhenLowBattery_CheckedChanged(object sender, EventArgs e)
{ {
Global.setFlashWhenLowBattery(device, flashLed.Checked); Global.setFlashWhenLowBattery(device, flashLed.Checked);
} }
private void touchAtStartCheckBox_CheckedChanged(object sender, EventArgs e)
{
Global.setTouchEnabled(device,touchCheckBox.Checked);
}
private void lowerRCOffCheckBox_CheckedChanged(object sender, EventArgs e) private void lowerRCOffCheckBox_CheckedChanged(object sender, EventArgs e)
{ {
if (realTimeChangesCheckBox.Checked) Global.setLowerRCOn(device, cBlowerRCOn.Checked);
Global.setLowerRCOff(device, !lowerRCOffCheckBox.Checked);
} }
private void touchpadJitterCompensation_CheckedChanged(object sender, EventArgs e) private void touchpadJitterCompensation_CheckedChanged(object sender, EventArgs e)
{ {
if (realTimeChangesCheckBox.Checked)
Global.setTouchpadJitterCompensation(device, touchpadJitterCompensation.Checked); Global.setTouchpadJitterCompensation(device, touchpadJitterCompensation.Checked);
} }
private void realTimeChangesCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (realTimeChangesCheckBox.Checked)
{
setButton.Visible = false;
}
else
{
setButton.Visible = true;
}
}
private void pictureBox_Click(object sender, EventArgs e) private void pictureBox_Click(object sender, EventArgs e)
{ {
if (lowLedCheckBox.Checked) if (lowLedCheckBox.Checked)
@ -462,7 +557,7 @@ namespace ScpServer
} }
private void colorChooserButton_Click(object sender, EventArgs e) private void colorChooserButton_Click(object sender, EventArgs e)
{ {
advColorDialog.Color = colorChooserButton.BackColor; advColorDialog.Color = Color.FromArgb(redBar.Value, greenBar.Value, blueBar.Value);
advColorDialog_OnUpdateColor(colorChooserButton.BackColor, e); advColorDialog_OnUpdateColor(colorChooserButton.BackColor, e);
if (advColorDialog.ShowDialog() == DialogResult.OK) if (advColorDialog.ShowDialog() == DialogResult.OK)
{ {
@ -470,7 +565,6 @@ namespace ScpServer
greenValLabel.Text = advColorDialog.Color.G.ToString(); greenValLabel.Text = advColorDialog.Color.G.ToString();
blueValLabel.Text = advColorDialog.Color.B.ToString(); blueValLabel.Text = advColorDialog.Color.B.ToString();
colorChooserButton.BackColor = advColorDialog.Color; colorChooserButton.BackColor = advColorDialog.Color;
pictureBox.BackColor = advColorDialog.Color;
if (!lowLedCheckBox.Checked) if (!lowLedCheckBox.Checked)
{ {
redBar.Value = advColorDialog.Color.R; redBar.Value = advColorDialog.Color.R;
@ -493,7 +587,6 @@ namespace ScpServer
lowGreenValLabel.Text = advColorDialog.Color.G.ToString(); lowGreenValLabel.Text = advColorDialog.Color.G.ToString();
lowBlueValLabel.Text = advColorDialog.Color.B.ToString(); lowBlueValLabel.Text = advColorDialog.Color.B.ToString();
lowColorChooserButton.BackColor = advColorDialog.Color; lowColorChooserButton.BackColor = advColorDialog.Color;
pictureBox.BackColor = advColorDialog.Color;
if (lowLedCheckBox.Checked) if (lowLedCheckBox.Checked)
{ {
redBar.Value = advColorDialog.Color.R; redBar.Value = advColorDialog.Color.R;
@ -528,8 +621,187 @@ namespace ScpServer
Global.setFlushHIDQueue(device, flushHIDQueue.Checked); Global.setFlushHIDQueue(device, flushHIDQueue.Checked);
} }
private void idleDisconnectTimeout_ValueChanged(object sender, EventArgs e)
{
if (idleDisconnectTimeout.Value <= 29 && idleDisconnectTimeout.Value > 15)
{
idleDisconnectTimeout.Value = 0;
Global.setIdleDisconnectTimeout(device, (int)idleDisconnectTimeout.Value);
}
else if (idleDisconnectTimeout.Value > 0 && idleDisconnectTimeout.Value <= 15)
{
idleDisconnectTimeout.Value = 30;
Global.setIdleDisconnectTimeout(device, (int)idleDisconnectTimeout.Value);
}
else
Global.setIdleDisconnectTimeout(device, (int)idleDisconnectTimeout.Value);
}
private void rumbleSwap_CheckedChanged(object sender, EventArgs e)
{
Global.setRumbleSwap(device, rumbleSwap.Checked);
}
private void Options_Closed(object sender, FormClosedEventArgs e)
{
Global.LoadProfile(device);
mainWin.RefreshProfiles();
}
private void tBProfile_TextChanged(object sender, EventArgs e)
{
if (tBProfile.Text != null && tBProfile.Text != "" && !tBProfile.Text.Contains("\\") && !tBProfile.Text.Contains("/") && !tBProfile.Text.Contains(":") && !tBProfile.Text.Contains("*") && !tBProfile.Text.Contains("?") && !tBProfile.Text.Contains("\"") && !tBProfile.Text.Contains("<") && !tBProfile.Text.Contains(">") && !tBProfile.Text.Contains("|"))
{
tBProfile.ForeColor = System.Drawing.SystemColors.WindowText;
}
else
tBProfile.ForeColor = System.Drawing.SystemColors.GrayText;
}
private void tBProfile_Enter(object sender, EventArgs e)
{
if (tBProfile.Text == "<type profile name here>")
tBProfile.Text = "";
}
private void tBProfile_Leave(object sender, EventArgs e)
{
if (tBProfile.Text == "")
tBProfile.Text = "<type profile name here>";
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (cBSlide.Checked)
numUDTouch.Value = 100;
else
numUDTouch.Value = 0;
numUDTouch.Enabled = cBSlide.Checked;
}
private void cBScroll_CheckedChanged(object sender, EventArgs e)
{
if (cBScroll.Checked)
numUDScroll.Value = 5;
else
numUDScroll.Value = 0;
numUDScroll.Enabled = cBScroll.Checked;
}
private void cBTap_CheckedChanged(object sender, EventArgs e)
{
if (cBTap.Checked)
numUDTap.Value = 100;
else
numUDTap.Value = 0;
numUDTap.Enabled = cBTap.Checked;
}
private void tbProfile_EnterDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
saveButton_Click(sender, e);
}
private void lBControls_SelectedIndexChanged(object sender, EventArgs e)
{
}
public void UpdateLists()
{
lBControls.Items[0] = "Cross : " + bnCross.Text;
lBControls.Items[1] = "Circle : " + bnCircle.Text;
lBControls.Items[2] = "Sqaure : " + bnSquare.Text;
lBControls.Items[3] = "Triangle : " + bnTriangle.Text;
lBControls.Items[4] = "Options : " + bnOptions.Text;
lBControls.Items[5] = "Share : " + bnShare.Text;
lBControls.Items[6] = "Up : " + bnUp.Text;
lBControls.Items[7] = "Down : " + bnDown.Text;
lBControls.Items[8] = "Left : " + bnLeft.Text;
lBControls.Items[9] = "Right : " + bnRight.Text;
lBControls.Items[10] = "PS : " + bnPS.Text;
lBControls.Items[11] = "L1 : " + bnL1.Text;
lBControls.Items[12] = "R1 : " + bnR1.Text;
lBControls.Items[13] = "L2 : " + bnL2.Text;
lBControls.Items[14] = "R2 : " + bnR2.Text;
lBControls.Items[15] = "L3 : " + bnL3.Text;
lBControls.Items[16] = "R3 : " + bnR3.Text;
lBControls.Items[17] = "Left Stick : " + bnLSUp.Text + ", " + bnLSDown.Text + ", " + bnLSLeft.Text + ", " + bnLSRight.Text;
lBControls.Items[18] = "Right Stick : " + bnRSUp.Text + ", " + bnRSDown.Text + ", " + bnRSLeft.Text + ", " + bnRSRight.Text;
lBControls.Items[19] = "Touchpad : " + bnTouchLeft.Text + ", " + bnTouchUpper.Text + ", " + bnTouchMulti.Text + ", " + bnTouchRight.Text;
lBAnalogSticks.Items[0] = lBControls.Items[15];
lBAnalogSticks.Items[1] = lBControls.Items[16];
lBAnalogSticks.Items[2] = "LS Up : " + bnLSUp.Text;
lBAnalogSticks.Items[3] = "LS Down : " + bnLSDown.Text;
lBAnalogSticks.Items[4] = "LS Left :" + bnLSLeft.Text;
lBAnalogSticks.Items[5] = "LS Right : " + bnLSRight.Text;
lBAnalogSticks.Items[6] = "RS Up : " + bnRSUp.Text;
lBAnalogSticks.Items[7] = "RS Down : " + bnRSDown.Text;
lBAnalogSticks.Items[8] = "RS Left : " + bnRSLeft.Text;
lBAnalogSticks.Items[9] = "RS Right : " + bnRSRight.Text;
lBTouchControls.Items[0] = "Left Side : " + bnTouchLeft.Text;
lBTouchControls.Items[1] = "Upperpad : " + bnTouchUpper.Text;
lBTouchControls.Items[2] = "Multitouch : " + bnTouchMulti.Text;
lBTouchControls.Items[3] = "Right Side : " + bnTouchRight.Text;
}
private void Show_ControlsList(object sender, EventArgs e)
{
if (tabOptions.SelectedTab == tabControls)
{
if (lBControls.SelectedIndex == 0) Show_ControlsBn(bnCross, e);
if (lBControls.SelectedIndex == 1) Show_ControlsBn(bnCircle, e);
if (lBControls.SelectedIndex == 2) Show_ControlsBn(bnSquare, e);
if (lBControls.SelectedIndex == 3) Show_ControlsBn(bnTriangle, e);
if (lBControls.SelectedIndex == 4) Show_ControlsBn(bnOptions, e);
if (lBControls.SelectedIndex == 5) Show_ControlsBn(bnShare, e);
if (lBControls.SelectedIndex == 6) Show_ControlsBn(bnUp, e);
if (lBControls.SelectedIndex == 7) Show_ControlsBn(bnDown, e);
if (lBControls.SelectedIndex == 8) Show_ControlsBn(bnLeft, e);
if (lBControls.SelectedIndex == 9) Show_ControlsBn(bnRight, e);
if (lBControls.SelectedIndex == 10) Show_ControlsBn(bnPS, e);
if (lBControls.SelectedIndex == 11) Show_ControlsBn(bnL1, e);
if (lBControls.SelectedIndex == 12) Show_ControlsBn(bnR1, e);
if (lBControls.SelectedIndex == 13) Show_ControlsBn(bnL2, e);
if (lBControls.SelectedIndex == 14) Show_ControlsBn(bnR2, e);
if (lBControls.SelectedIndex == 15) Show_ControlsBn(bnL3, e);
if (lBControls.SelectedIndex == 16) Show_ControlsBn(bnR3, e);
if (lBControls.SelectedIndex == 17) tabOptions.SelectTab(1);
if (lBControls.SelectedIndex == 18) tabOptions.SelectTab(1);
if (lBControls.SelectedIndex == 19) tabOptions.SelectTab(2);
}
else if (tabOptions.SelectedTab == tabAnalogSticks)
{
if (lBAnalogSticks.SelectedIndex == 0) Show_ControlsBn(bnL3, e);
if (lBAnalogSticks.SelectedIndex == 1) Show_ControlsBn(bnR3, e);
if (lBAnalogSticks.SelectedIndex == 2) Show_ControlsBn(bnLSUp, e);
if (lBAnalogSticks.SelectedIndex == 3) Show_ControlsBn(bnLSDown, e);
if (lBAnalogSticks.SelectedIndex == 4) Show_ControlsBn(bnLSLeft, e);
if (lBAnalogSticks.SelectedIndex == 5) Show_ControlsBn(bnLSRight, e);
if (lBAnalogSticks.SelectedIndex == 6) Show_ControlsBn(bnRSUp, e);
if (lBAnalogSticks.SelectedIndex == 7) Show_ControlsBn(bnRSDown, e);
if (lBAnalogSticks.SelectedIndex == 8) Show_ControlsBn(bnCircle, e);
if (lBAnalogSticks.SelectedIndex == 9) Show_ControlsBn(bnRSRight, e);
}
else if (tabOptions.SelectedTab == tabTouchPad)
{
if (lBTouchControls.SelectedIndex == 0) Show_ControlsBn(bnTouchLeft, e);
if (lBTouchControls.SelectedIndex == 1) Show_ControlsBn(bnTouchUpper, e);
if (lBTouchControls.SelectedIndex == 2) Show_ControlsBn(bnTouchMulti, e);
if (lBTouchControls.SelectedIndex == 3) Show_ControlsBn(bnTouchRight, e);
}
}
private void List_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show_ControlsList(sender, e);
}
private void List_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
Show_ControlsList(sender, e);
}
} }
} }

View File

@ -129,97 +129,19 @@
<value>Stop</value> <value>Stop</value>
<comment>To be localized.</comment> <comment>To be localized.</comment>
</data> </data>
<data name="_1" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="sticks2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\sticks2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="_10" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="_360_fades" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\10.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\360 fades.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="_11" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="DS4_Controller" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\11.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\DS4 Controller.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="_12" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Touch_states2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\12.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\Touch states2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="_13" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="mouse" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\13.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\mouse.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_14" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\14.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_15" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\15.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_17" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\17.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_18" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\18.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_19" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\19.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_20" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\20.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_21" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\21.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_22" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\22.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_23" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\23.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_25" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\25.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_26" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\26.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_27" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\27.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_28" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\28.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_29" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\29.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_30" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\30.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_31" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\31.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\4.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_5" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\5.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_6" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\6.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_7" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\7.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_8" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\8.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_9" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\9.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
</root> </root>

141
DS4Tool/Properties/Resources1.Designer.cs generated Normal file
View File

@ -0,0 +1,141 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ScpServer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ScpServer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap _360_fades {
get {
object obj = ResourceManager.GetObject("_360_fades", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
public static System.Drawing.Icon DS4 {
get {
object obj = ResourceManager.GetObject("DS4", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap DS4_Controller {
get {
object obj = ResourceManager.GetObject("DS4_Controller", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap mouse {
get {
object obj = ResourceManager.GetObject("mouse", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to Start.
/// </summary>
public static string Start {
get {
return ResourceManager.GetString("Start", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap sticks2 {
get {
object obj = ResourceManager.GetObject("sticks2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to Stop.
/// </summary>
public static string Stop {
get {
return ResourceManager.GetString("Stop", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap Touch_states2 {
get {
object obj = ResourceManager.GetObject("Touch_states2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
DS4Tool/Resources/mouse.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -39,19 +39,34 @@
this.btnStartStop = new System.Windows.Forms.Button(); this.btnStartStop = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button();
this.btnStop = new System.Windows.Forms.Button(); this.btnStop = new System.Windows.Forms.Button();
this.hotkeysButton = new System.Windows.Forms.Button();
this.lnkControllers = new System.Windows.Forms.LinkLabel(); this.lnkControllers = new System.Windows.Forms.LinkLabel();
this.hideDS4CheckBox = new System.Windows.Forms.CheckBox();
this.startMinimizedCheckBox = new System.Windows.Forms.CheckBox();
this.pnlDebug = new System.Windows.Forms.Panel(); this.pnlDebug = new System.Windows.Forms.Panel();
this.pnlStatus = new System.Windows.Forms.Panel(); this.pnlStatus = new System.Windows.Forms.Panel();
this.gpPads = new System.Windows.Forms.GroupBox(); this.gpPads = new System.Windows.Forms.GroupBox();
this.lbSelPro4 = new System.Windows.Forms.Label();
this.lbSelPro3 = new System.Windows.Forms.Label();
this.lbSelPro2 = new System.Windows.Forms.Label();
this.lbSelPro1 = new System.Windows.Forms.Label();
this.lbPad4 = new System.Windows.Forms.Label();
this.lbPad3 = new System.Windows.Forms.Label();
this.lbPad2 = new System.Windows.Forms.Label();
this.lbPad1 = new System.Windows.Forms.Label();
this.bnEditC4 = new System.Windows.Forms.Button();
this.bnEditC3 = new System.Windows.Forms.Button();
this.bnEditC2 = new System.Windows.Forms.Button();
this.bnDeleteC4 = new System.Windows.Forms.Button();
this.bnDeleteC3 = new System.Windows.Forms.Button();
this.bnDeleteC2 = new System.Windows.Forms.Button();
this.bnDeleteC1 = new System.Windows.Forms.Button();
this.bnEditC1 = new System.Windows.Forms.Button();
this.cBController4 = new System.Windows.Forms.ComboBox();
this.cBController3 = new System.Windows.Forms.ComboBox();
this.cBController2 = new System.Windows.Forms.ComboBox();
this.cBController1 = new System.Windows.Forms.ComboBox();
this.lbLastMessage = new System.Windows.Forms.Label(); this.lbLastMessage = new System.Windows.Forms.Label();
this.startMinimizedCheckBox = new System.Windows.Forms.CheckBox();
this.hideDS4CheckBox = new System.Windows.Forms.CheckBox();
this.hotkeysButton = new System.Windows.Forms.Button();
this.optionsButton = new System.Windows.Forms.Button();
this.rbPad_4 = new System.Windows.Forms.RadioButton();
this.rbPad_3 = new System.Windows.Forms.RadioButton();
this.rbPad_2 = new System.Windows.Forms.RadioButton();
this.rbPad_1 = new System.Windows.Forms.RadioButton();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.pnlButton.SuspendLayout(); this.pnlButton.SuspendLayout();
this.pnlDebug.SuspendLayout(); this.pnlDebug.SuspendLayout();
@ -98,10 +113,12 @@
this.pnlButton.Controls.Add(this.btnStartStop); this.pnlButton.Controls.Add(this.btnStartStop);
this.pnlButton.Controls.Add(this.btnClear); this.pnlButton.Controls.Add(this.btnClear);
this.pnlButton.Controls.Add(this.btnStop); this.pnlButton.Controls.Add(this.btnStop);
this.pnlButton.Controls.Add(this.hotkeysButton);
this.pnlButton.Controls.Add(this.lnkControllers);
this.pnlButton.Dock = System.Windows.Forms.DockStyle.Bottom; this.pnlButton.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlButton.Location = new System.Drawing.Point(0, 477); this.pnlButton.Location = new System.Drawing.Point(3, 477);
this.pnlButton.Name = "pnlButton"; this.pnlButton.Name = "pnlButton";
this.pnlButton.Size = new System.Drawing.Size(794, 35); this.pnlButton.Size = new System.Drawing.Size(791, 35);
this.pnlButton.TabIndex = 10; this.pnlButton.TabIndex = 10;
// //
// AboutButton // AboutButton
@ -150,95 +167,9 @@
this.btnStop.Visible = false; this.btnStop.Visible = false;
this.btnStop.Click += new System.EventHandler(this.btnStop_Click); this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
// //
// lnkControllers
//
this.lnkControllers.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lnkControllers.AutoSize = true;
this.lnkControllers.Location = new System.Drawing.Point(495, 96);
this.lnkControllers.Name = "lnkControllers";
this.lnkControllers.Size = new System.Drawing.Size(56, 13);
this.lnkControllers.TabIndex = 11;
this.lnkControllers.TabStop = true;
this.lnkControllers.Text = "Controllers";
this.lnkControllers.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkControllers_LinkClicked);
//
// pnlDebug
//
this.pnlDebug.Controls.Add(this.lvDebug);
this.pnlDebug.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlDebug.Location = new System.Drawing.Point(0, 124);
this.pnlDebug.Name = "pnlDebug";
this.pnlDebug.Size = new System.Drawing.Size(794, 353);
this.pnlDebug.TabIndex = 11;
//
// pnlStatus
//
this.pnlStatus.Controls.Add(this.gpPads);
this.pnlStatus.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlStatus.Location = new System.Drawing.Point(0, 0);
this.pnlStatus.Name = "pnlStatus";
this.pnlStatus.Size = new System.Drawing.Size(794, 124);
this.pnlStatus.TabIndex = 9;
//
// gpPads
//
this.gpPads.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gpPads.Controls.Add(this.lnkControllers);
this.gpPads.Controls.Add(this.lbLastMessage);
this.gpPads.Controls.Add(this.startMinimizedCheckBox);
this.gpPads.Controls.Add(this.hideDS4CheckBox);
this.gpPads.Controls.Add(this.hotkeysButton);
this.gpPads.Controls.Add(this.optionsButton);
this.gpPads.Controls.Add(this.rbPad_4);
this.gpPads.Controls.Add(this.rbPad_3);
this.gpPads.Controls.Add(this.rbPad_2);
this.gpPads.Controls.Add(this.rbPad_1);
this.gpPads.Location = new System.Drawing.Point(3, 3);
this.gpPads.Name = "gpPads";
this.gpPads.Size = new System.Drawing.Size(791, 117);
this.gpPads.TabIndex = 1;
this.gpPads.TabStop = false;
//
// lbLastMessage
//
this.lbLastMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.lbLastMessage.ForeColor = System.Drawing.SystemColors.GrayText;
this.lbLastMessage.Location = new System.Drawing.Point(58, 94);
this.lbLastMessage.Name = "lbLastMessage";
this.lbLastMessage.Size = new System.Drawing.Size(438, 17);
this.lbLastMessage.TabIndex = 41;
this.lbLastMessage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lbLastMessage.Visible = false;
//
// startMinimizedCheckBox
//
this.startMinimizedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.startMinimizedCheckBox.AutoSize = true;
this.startMinimizedCheckBox.Location = new System.Drawing.Point(557, 94);
this.startMinimizedCheckBox.Name = "startMinimizedCheckBox";
this.startMinimizedCheckBox.Size = new System.Drawing.Size(97, 17);
this.startMinimizedCheckBox.TabIndex = 40;
this.startMinimizedCheckBox.Text = "Start Minimized";
this.startMinimizedCheckBox.UseVisualStyleBackColor = true;
this.startMinimizedCheckBox.CheckedChanged += new System.EventHandler(this.startMinimizedCheckBox_CheckedChanged);
//
// hideDS4CheckBox
//
this.hideDS4CheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.hideDS4CheckBox.AutoSize = true;
this.hideDS4CheckBox.Location = new System.Drawing.Point(660, 94);
this.hideDS4CheckBox.Name = "hideDS4CheckBox";
this.hideDS4CheckBox.Size = new System.Drawing.Size(119, 17);
this.hideDS4CheckBox.TabIndex = 13;
this.hideDS4CheckBox.Text = "Hide DS4 Controller";
this.hideDS4CheckBox.UseVisualStyleBackColor = true;
this.hideDS4CheckBox.CheckedChanged += new System.EventHandler(this.hideDS4CheckBox_CheckedChanged);
//
// hotkeysButton // hotkeysButton
// //
this.hotkeysButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.hotkeysButton.Location = new System.Drawing.Point(90, 5);
this.hotkeysButton.Location = new System.Drawing.Point(704, 50);
this.hotkeysButton.Name = "hotkeysButton"; this.hotkeysButton.Name = "hotkeysButton";
this.hotkeysButton.Size = new System.Drawing.Size(75, 23); this.hotkeysButton.Size = new System.Drawing.Size(75, 23);
this.hotkeysButton.TabIndex = 12; this.hotkeysButton.TabIndex = 12;
@ -246,68 +177,330 @@
this.hotkeysButton.UseVisualStyleBackColor = true; this.hotkeysButton.UseVisualStyleBackColor = true;
this.hotkeysButton.Click += new System.EventHandler(this.hotkeysButton_Click); this.hotkeysButton.Click += new System.EventHandler(this.hotkeysButton_Click);
// //
// optionsButton // lnkControllers
// //
this.optionsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lnkControllers.AutoSize = true;
this.optionsButton.Location = new System.Drawing.Point(704, 10); this.lnkControllers.Location = new System.Drawing.Point(171, 10);
this.optionsButton.Name = "optionsButton"; this.lnkControllers.Name = "lnkControllers";
this.optionsButton.Size = new System.Drawing.Size(75, 23); this.lnkControllers.Size = new System.Drawing.Size(56, 13);
this.optionsButton.TabIndex = 11; this.lnkControllers.TabIndex = 11;
this.optionsButton.Text = "Options"; this.lnkControllers.TabStop = true;
this.optionsButton.UseVisualStyleBackColor = true; this.lnkControllers.Text = "Controllers";
this.optionsButton.Click += new System.EventHandler(this.optionsButton_Click); this.lnkControllers.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkControllers_LinkClicked);
// //
// rbPad_4 // hideDS4CheckBox
// //
this.rbPad_4.AutoSize = true; this.hideDS4CheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.rbPad_4.Enabled = false; this.hideDS4CheckBox.AutoSize = true;
this.rbPad_4.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.hideDS4CheckBox.Location = new System.Drawing.Point(672, 109);
this.rbPad_4.Location = new System.Drawing.Point(6, 79); this.hideDS4CheckBox.Name = "hideDS4CheckBox";
this.rbPad_4.Name = "rbPad_4"; this.hideDS4CheckBox.Size = new System.Drawing.Size(119, 17);
this.rbPad_4.Size = new System.Drawing.Size(185, 17); this.hideDS4CheckBox.TabIndex = 13;
this.rbPad_4.TabIndex = 3; this.hideDS4CheckBox.Text = "Hide DS4 Controller";
this.rbPad_4.TabStop = true; this.hideDS4CheckBox.UseVisualStyleBackColor = true;
this.rbPad_4.Text = "Pad 4 : Disconnected"; this.hideDS4CheckBox.CheckedChanged += new System.EventHandler(this.hideDS4CheckBox_CheckedChanged);
this.rbPad_4.UseVisualStyleBackColor = true;
// //
// rbPad_3 // startMinimizedCheckBox
// //
this.rbPad_3.AutoSize = true; this.startMinimizedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.rbPad_3.Enabled = false; this.startMinimizedCheckBox.AutoSize = true;
this.rbPad_3.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.startMinimizedCheckBox.Location = new System.Drawing.Point(569, 109);
this.rbPad_3.Location = new System.Drawing.Point(6, 56); this.startMinimizedCheckBox.Name = "startMinimizedCheckBox";
this.rbPad_3.Name = "rbPad_3"; this.startMinimizedCheckBox.Size = new System.Drawing.Size(97, 17);
this.rbPad_3.Size = new System.Drawing.Size(185, 17); this.startMinimizedCheckBox.TabIndex = 40;
this.rbPad_3.TabIndex = 2; this.startMinimizedCheckBox.Text = "Start Minimized";
this.rbPad_3.TabStop = true; this.startMinimizedCheckBox.UseVisualStyleBackColor = true;
this.rbPad_3.Text = "Pad 3 : Disconnected"; this.startMinimizedCheckBox.CheckedChanged += new System.EventHandler(this.startMinimizedCheckBox_CheckedChanged);
this.rbPad_3.UseVisualStyleBackColor = true;
// //
// rbPad_2 // pnlDebug
// //
this.rbPad_2.AutoSize = true; this.pnlDebug.Controls.Add(this.lvDebug);
this.rbPad_2.Enabled = false; this.pnlDebug.Dock = System.Windows.Forms.DockStyle.Fill;
this.rbPad_2.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.pnlDebug.Location = new System.Drawing.Point(3, 124);
this.rbPad_2.Location = new System.Drawing.Point(6, 33); this.pnlDebug.Name = "pnlDebug";
this.rbPad_2.Name = "rbPad_2"; this.pnlDebug.Size = new System.Drawing.Size(791, 353);
this.rbPad_2.Size = new System.Drawing.Size(185, 17); this.pnlDebug.TabIndex = 11;
this.rbPad_2.TabIndex = 1;
this.rbPad_2.TabStop = true;
this.rbPad_2.Text = "Pad 2 : Disconnected";
this.rbPad_2.UseVisualStyleBackColor = true;
// //
// rbPad_1 // pnlStatus
// //
this.rbPad_1.AutoSize = true; this.pnlStatus.Controls.Add(this.gpPads);
this.rbPad_1.Enabled = false; this.pnlStatus.Dock = System.Windows.Forms.DockStyle.Top;
this.rbPad_1.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.pnlStatus.Location = new System.Drawing.Point(3, 0);
this.rbPad_1.Location = new System.Drawing.Point(6, 10); this.pnlStatus.Name = "pnlStatus";
this.rbPad_1.Name = "rbPad_1"; this.pnlStatus.Size = new System.Drawing.Size(791, 124);
this.rbPad_1.Size = new System.Drawing.Size(185, 17); this.pnlStatus.TabIndex = 9;
this.rbPad_1.TabIndex = 0; //
this.rbPad_1.TabStop = true; // gpPads
this.rbPad_1.Text = "Pad 1 : Disconnected"; //
this.rbPad_1.UseVisualStyleBackColor = true; this.gpPads.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gpPads.Controls.Add(this.lbSelPro4);
this.gpPads.Controls.Add(this.lbSelPro3);
this.gpPads.Controls.Add(this.lbSelPro2);
this.gpPads.Controls.Add(this.lbSelPro1);
this.gpPads.Controls.Add(this.lbPad4);
this.gpPads.Controls.Add(this.lbPad3);
this.gpPads.Controls.Add(this.lbPad2);
this.gpPads.Controls.Add(this.lbPad1);
this.gpPads.Controls.Add(this.bnEditC4);
this.gpPads.Controls.Add(this.bnEditC3);
this.gpPads.Controls.Add(this.hideDS4CheckBox);
this.gpPads.Controls.Add(this.bnEditC2);
this.gpPads.Controls.Add(this.startMinimizedCheckBox);
this.gpPads.Controls.Add(this.bnDeleteC4);
this.gpPads.Controls.Add(this.bnDeleteC3);
this.gpPads.Controls.Add(this.bnDeleteC2);
this.gpPads.Controls.Add(this.bnDeleteC1);
this.gpPads.Controls.Add(this.bnEditC1);
this.gpPads.Controls.Add(this.cBController4);
this.gpPads.Controls.Add(this.cBController3);
this.gpPads.Controls.Add(this.cBController2);
this.gpPads.Controls.Add(this.cBController1);
this.gpPads.Controls.Add(this.lbLastMessage);
this.gpPads.Location = new System.Drawing.Point(-6, -9);
this.gpPads.Name = "gpPads";
this.gpPads.Size = new System.Drawing.Size(800, 129);
this.gpPads.TabIndex = 1;
this.gpPads.TabStop = false;
//
// lbSelPro4
//
this.lbSelPro4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lbSelPro4.AutoSize = true;
this.lbSelPro4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbSelPro4.Location = new System.Drawing.Point(467, 86);
this.lbSelPro4.Name = "lbSelPro4";
this.lbSelPro4.Size = new System.Drawing.Size(96, 15);
this.lbSelPro4.TabIndex = 45;
this.lbSelPro4.Text = "Selected Profile:";
//
// lbSelPro3
//
this.lbSelPro3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lbSelPro3.AutoSize = true;
this.lbSelPro3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbSelPro3.Location = new System.Drawing.Point(467, 62);
this.lbSelPro3.Name = "lbSelPro3";
this.lbSelPro3.Size = new System.Drawing.Size(96, 15);
this.lbSelPro3.TabIndex = 45;
this.lbSelPro3.Text = "Selected Profile:";
//
// lbSelPro2
//
this.lbSelPro2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lbSelPro2.AutoSize = true;
this.lbSelPro2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbSelPro2.Location = new System.Drawing.Point(467, 40);
this.lbSelPro2.Name = "lbSelPro2";
this.lbSelPro2.Size = new System.Drawing.Size(96, 15);
this.lbSelPro2.TabIndex = 45;
this.lbSelPro2.Text = "Selected Profile:";
//
// lbSelPro1
//
this.lbSelPro1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lbSelPro1.AutoSize = true;
this.lbSelPro1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbSelPro1.Location = new System.Drawing.Point(467, 17);
this.lbSelPro1.Name = "lbSelPro1";
this.lbSelPro1.Size = new System.Drawing.Size(96, 15);
this.lbSelPro1.TabIndex = 45;
this.lbSelPro1.Text = "Selected Profile:";
//
// lbPad4
//
this.lbPad4.AutoSize = true;
this.lbPad4.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbPad4.Location = new System.Drawing.Point(12, 89);
this.lbPad4.Name = "lbPad4";
this.lbPad4.Size = new System.Drawing.Size(167, 13);
this.lbPad4.TabIndex = 44;
this.lbPad4.Text = "Pad 4 : Disconnected";
//
// lbPad3
//
this.lbPad3.AutoSize = true;
this.lbPad3.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbPad3.Location = new System.Drawing.Point(12, 66);
this.lbPad3.Name = "lbPad3";
this.lbPad3.Size = new System.Drawing.Size(167, 13);
this.lbPad3.TabIndex = 44;
this.lbPad3.Text = "Pad 3 : Disconnected";
//
// lbPad2
//
this.lbPad2.AutoSize = true;
this.lbPad2.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbPad2.Location = new System.Drawing.Point(12, 43);
this.lbPad2.Name = "lbPad2";
this.lbPad2.Size = new System.Drawing.Size(167, 13);
this.lbPad2.TabIndex = 44;
this.lbPad2.Text = "Pad 2 : Disconnected";
//
// lbPad1
//
this.lbPad1.AutoSize = true;
this.lbPad1.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbPad1.Location = new System.Drawing.Point(12, 19);
this.lbPad1.Name = "lbPad1";
this.lbPad1.Size = new System.Drawing.Size(167, 13);
this.lbPad1.TabIndex = 44;
this.lbPad1.Text = "Pad 1 : Disconnected";
//
// bnEditC4
//
this.bnEditC4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bnEditC4.Location = new System.Drawing.Point(695, 83);
this.bnEditC4.Name = "bnEditC4";
this.bnEditC4.Size = new System.Drawing.Size(40, 23);
this.bnEditC4.TabIndex = 43;
this.bnEditC4.Tag = "3";
this.bnEditC4.Text = "Edit";
this.bnEditC4.UseVisualStyleBackColor = true;
this.bnEditC4.Click += new System.EventHandler(this.editButtons_Click);
//
// bnEditC3
//
this.bnEditC3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bnEditC3.Location = new System.Drawing.Point(695, 60);
this.bnEditC3.Name = "bnEditC3";
this.bnEditC3.Size = new System.Drawing.Size(40, 23);
this.bnEditC3.TabIndex = 43;
this.bnEditC3.Tag = "2";
this.bnEditC3.Text = "Edit";
this.bnEditC3.UseVisualStyleBackColor = true;
this.bnEditC3.Click += new System.EventHandler(this.editButtons_Click);
//
// bnEditC2
//
this.bnEditC2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bnEditC2.Location = new System.Drawing.Point(695, 37);
this.bnEditC2.Name = "bnEditC2";
this.bnEditC2.Size = new System.Drawing.Size(40, 23);
this.bnEditC2.TabIndex = 43;
this.bnEditC2.Tag = "1";
this.bnEditC2.Text = "Edit";
this.bnEditC2.UseVisualStyleBackColor = true;
this.bnEditC2.Click += new System.EventHandler(this.editButtons_Click);
//
// bnDeleteC4
//
this.bnDeleteC4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bnDeleteC4.Location = new System.Drawing.Point(741, 83);
this.bnDeleteC4.Name = "bnDeleteC4";
this.bnDeleteC4.Size = new System.Drawing.Size(47, 23);
this.bnDeleteC4.TabIndex = 43;
this.bnDeleteC4.Tag = "3";
this.bnDeleteC4.Text = "Delete";
this.bnDeleteC4.UseVisualStyleBackColor = true;
this.bnDeleteC4.Click += new System.EventHandler(this.deleteButtons_Click);
//
// bnDeleteC3
//
this.bnDeleteC3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bnDeleteC3.Location = new System.Drawing.Point(741, 60);
this.bnDeleteC3.Name = "bnDeleteC3";
this.bnDeleteC3.Size = new System.Drawing.Size(47, 23);
this.bnDeleteC3.TabIndex = 43;
this.bnDeleteC3.Tag = "2";
this.bnDeleteC3.Text = "Delete";
this.bnDeleteC3.UseVisualStyleBackColor = true;
this.bnDeleteC3.Click += new System.EventHandler(this.deleteButtons_Click);
//
// bnDeleteC2
//
this.bnDeleteC2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bnDeleteC2.Location = new System.Drawing.Point(741, 37);
this.bnDeleteC2.Name = "bnDeleteC2";
this.bnDeleteC2.Size = new System.Drawing.Size(47, 23);
this.bnDeleteC2.TabIndex = 43;
this.bnDeleteC2.Tag = "1";
this.bnDeleteC2.Text = "Delete";
this.bnDeleteC2.UseVisualStyleBackColor = true;
this.bnDeleteC2.Click += new System.EventHandler(this.deleteButtons_Click);
//
// bnDeleteC1
//
this.bnDeleteC1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bnDeleteC1.Location = new System.Drawing.Point(741, 13);
this.bnDeleteC1.Name = "bnDeleteC1";
this.bnDeleteC1.Size = new System.Drawing.Size(47, 23);
this.bnDeleteC1.TabIndex = 43;
this.bnDeleteC1.Tag = "0";
this.bnDeleteC1.Text = "Delete";
this.bnDeleteC1.UseVisualStyleBackColor = true;
this.bnDeleteC1.Click += new System.EventHandler(this.deleteButtons_Click);
//
// bnEditC1
//
this.bnEditC1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bnEditC1.Location = new System.Drawing.Point(695, 13);
this.bnEditC1.Name = "bnEditC1";
this.bnEditC1.Size = new System.Drawing.Size(40, 23);
this.bnEditC1.TabIndex = 43;
this.bnEditC1.Tag = "0";
this.bnEditC1.Text = "Edit";
this.bnEditC1.UseVisualStyleBackColor = true;
this.bnEditC1.Click += new System.EventHandler(this.editButtons_Click);
//
// cBController4
//
this.cBController4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cBController4.Enabled = false;
this.cBController4.FormattingEnabled = true;
this.cBController4.Location = new System.Drawing.Point(568, 84);
this.cBController4.Name = "cBController4";
this.cBController4.Size = new System.Drawing.Size(121, 21);
this.cBController4.TabIndex = 42;
this.cBController4.Tag = "3";
this.cBController4.SelectedValueChanged += new System.EventHandler(this.Profile_Changed);
//
// cBController3
//
this.cBController3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cBController3.Enabled = false;
this.cBController3.FormattingEnabled = true;
this.cBController3.Location = new System.Drawing.Point(568, 61);
this.cBController3.Name = "cBController3";
this.cBController3.Size = new System.Drawing.Size(121, 21);
this.cBController3.TabIndex = 42;
this.cBController3.Tag = "2";
this.cBController3.SelectedValueChanged += new System.EventHandler(this.Profile_Changed);
//
// cBController2
//
this.cBController2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cBController2.Enabled = false;
this.cBController2.FormattingEnabled = true;
this.cBController2.Location = new System.Drawing.Point(568, 38);
this.cBController2.Name = "cBController2";
this.cBController2.Size = new System.Drawing.Size(121, 21);
this.cBController2.TabIndex = 42;
this.cBController2.Tag = "1";
this.cBController2.SelectedValueChanged += new System.EventHandler(this.Profile_Changed);
//
// cBController1
//
this.cBController1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cBController1.Enabled = false;
this.cBController1.FormattingEnabled = true;
this.cBController1.Location = new System.Drawing.Point(568, 15);
this.cBController1.Name = "cBController1";
this.cBController1.Size = new System.Drawing.Size(121, 21);
this.cBController1.TabIndex = 42;
this.cBController1.Tag = "0";
this.cBController1.SelectedValueChanged += new System.EventHandler(this.Profile_Changed);
//
// lbLastMessage
//
this.lbLastMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.lbLastMessage.ForeColor = System.Drawing.SystemColors.GrayText;
this.lbLastMessage.Location = new System.Drawing.Point(15, 107);
this.lbLastMessage.Name = "lbLastMessage";
this.lbLastMessage.Size = new System.Drawing.Size(548, 20);
this.lbLastMessage.TabIndex = 41;
this.lbLastMessage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lbLastMessage.Visible = false;
// //
// notifyIcon1 // notifyIcon1
// //
@ -325,13 +518,14 @@
this.Controls.Add(this.pnlDebug); this.Controls.Add(this.pnlDebug);
this.Controls.Add(this.pnlButton); this.Controls.Add(this.pnlButton);
this.Controls.Add(this.pnlStatus); this.Controls.Add(this.pnlStatus);
this.MinimumSize = new System.Drawing.Size(750, 192); this.MinimumSize = new System.Drawing.Size(560, 192);
this.Name = "ScpForm"; this.Name = "ScpForm";
this.Text = "DS4Windows 1.0 Alpha 2 (2014-03-30.0)"; this.Text = "DS4Windows 1.0 Beta J2K Build";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form_Close); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form_Close);
this.Load += new System.EventHandler(this.Form_Load); this.Load += new System.EventHandler(this.Form_Load);
this.Resize += new System.EventHandler(this.Form_Resize); this.Resize += new System.EventHandler(this.Form_Resize);
this.pnlButton.ResumeLayout(false); this.pnlButton.ResumeLayout(false);
this.pnlButton.PerformLayout();
this.pnlDebug.ResumeLayout(false); this.pnlDebug.ResumeLayout(false);
this.pnlStatus.ResumeLayout(false); this.pnlStatus.ResumeLayout(false);
this.gpPads.ResumeLayout(false); this.gpPads.ResumeLayout(false);
@ -353,11 +547,6 @@
private System.Windows.Forms.Button btnClear; private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.Panel pnlStatus; private System.Windows.Forms.Panel pnlStatus;
private System.Windows.Forms.GroupBox gpPads; private System.Windows.Forms.GroupBox gpPads;
private System.Windows.Forms.Button optionsButton;
private System.Windows.Forms.RadioButton rbPad_4;
private System.Windows.Forms.RadioButton rbPad_3;
private System.Windows.Forms.RadioButton rbPad_2;
private System.Windows.Forms.RadioButton rbPad_1;
private System.Windows.Forms.NotifyIcon notifyIcon1; private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.Button hotkeysButton; private System.Windows.Forms.Button hotkeysButton;
private System.Windows.Forms.CheckBox hideDS4CheckBox; private System.Windows.Forms.CheckBox hideDS4CheckBox;
@ -365,6 +554,26 @@
private System.Windows.Forms.Label lbLastMessage; private System.Windows.Forms.Label lbLastMessage;
private System.Windows.Forms.LinkLabel lnkControllers; private System.Windows.Forms.LinkLabel lnkControllers;
private System.Windows.Forms.Button AboutButton; private System.Windows.Forms.Button AboutButton;
private System.Windows.Forms.ComboBox cBController4;
private System.Windows.Forms.ComboBox cBController3;
private System.Windows.Forms.ComboBox cBController2;
private System.Windows.Forms.ComboBox cBController1;
private System.Windows.Forms.Button bnEditC4;
private System.Windows.Forms.Button bnEditC3;
private System.Windows.Forms.Button bnEditC2;
private System.Windows.Forms.Button bnEditC1;
private System.Windows.Forms.Button bnDeleteC1;
private System.Windows.Forms.Button bnDeleteC4;
private System.Windows.Forms.Button bnDeleteC3;
private System.Windows.Forms.Button bnDeleteC2;
private System.Windows.Forms.Label lbPad4;
private System.Windows.Forms.Label lbPad3;
private System.Windows.Forms.Label lbPad2;
private System.Windows.Forms.Label lbPad1;
private System.Windows.Forms.Label lbSelPro1;
private System.Windows.Forms.Label lbSelPro4;
private System.Windows.Forms.Label lbSelPro3;
private System.Windows.Forms.Label lbSelPro2;
} }
} }

View File

@ -3,6 +3,9 @@ using System.Windows.Forms;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using DS4Control; using DS4Control;
using System.Threading; using System.Threading;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
namespace ScpServer namespace ScpServer
{ {
public partial class ScpForm : Form public partial class ScpForm : Form
@ -23,7 +26,7 @@ namespace ScpServer
} }
else else
{ {
String Posted = Time.ToString() + "." + Time.Millisecond.ToString("000"); String Posted = Time.ToString("O");
lvDebug.Items.Add(new ListViewItem(new String[] { Posted, Data })).EnsureVisible(); lvDebug.Items.Add(new ListViewItem(new String[] { Posted, Data })).EnsureVisible();
@ -57,9 +60,19 @@ namespace ScpServer
if (this.Height > 220) if (this.Height > 220)
lbLastMessage.Visible = false; lbLastMessage.Visible = false;
else lbLastMessage.Visible = true; else lbLastMessage.Visible = true;
for (int i = 0; i < 4; i++)
if (this.Width > 665)
protexts[i].Visible = true;
else
protexts[i].Visible = false;
} }
protected RadioButton[] Pad = new RadioButton[4]; protected Label[] Pads;
protected ComboBox[] cbs;
protected Button[] ebns;
protected Button[] dbns;
protected Label[] protexts;
public ScpForm() public ScpForm()
{ {
@ -67,10 +80,11 @@ namespace ScpServer
ThemeUtil.SetTheme(lvDebug); ThemeUtil.SetTheme(lvDebug);
Pad[0] = rbPad_1; Pads = new Label[4] { lbPad1, lbPad2, lbPad3, lbPad4 };
Pad[1] = rbPad_2; cbs = new ComboBox[4] { cBController1, cBController2, cBController3, cBController4 };
Pad[2] = rbPad_3; ebns = new Button[4] { bnEditC1, bnEditC2, bnEditC3, bnEditC4 };
Pad[3] = rbPad_4; dbns = new Button[4] { bnDeleteC1, bnDeleteC2, bnDeleteC3, bnDeleteC4 };
protexts = new Label[4] { lbSelPro1, lbSelPro2, lbSelPro3, lbSelPro4 };
} }
protected void Form_Load(object sender, EventArgs e) protected void Form_Load(object sender, EventArgs e)
@ -99,12 +113,53 @@ namespace ScpServer
this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Minimized;
Form_Resize(sender, e); Form_Resize(sender, e);
} }
Global.loadCustomMapping(0); RefreshProfiles();
for (int i = 0; i < 4; i++)
{
//Global.LoadProfile(i);
//Global.loadNEW(i, MapSelector.ButtonMode);
}
Global.ControllerStatusChange += ControllerStatusChange; Global.ControllerStatusChange += ControllerStatusChange;
ControllerStatusChanged(); ControllerStatusChanged();
if (btnStartStop.Enabled) if (btnStartStop.Enabled)
btnStartStop_Clicked(); btnStartStop_Clicked();
} }
public void RefreshProfiles()
{
try
{
string[] profiles = System.IO.Directory.GetFiles(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\");
int cutoff = (Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\").Length;
for (int i = 0; i < 4; i++)
{
cbs[i].Items.Clear();
string defaultprofile = Global.getAProfile(i);
string[] profileA = defaultprofile.Split('\\');
string filename = profileA[profileA.Length - 1];
foreach (String s in profiles)
if (s.EndsWith(".xml"))
cbs[i].Items.Add(s.Substring(cutoff, s.Length - 4 - cutoff));
for (int j = 0; j < cbs[i].Items.Count; j++)
if (cbs[i].Items[j] + ".xml" == filename)
{
cbs[i].SelectedIndex = j;
Profile_Changed(cbs[i], null);
break;
}
cbs[i].Items.Add("+New Profile");
}
}
catch (DirectoryNotFoundException)
{
System.IO.Directory.CreateDirectory(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\");
for (int i = 0; i < 4; i++)
{
cbs[i].Items.Add("");
cbs[i].SelectedIndex = 0;
cbs[i].Items.Add("+New Profile");
}
}
}
protected void Form_Close(object sender, FormClosingEventArgs e) protected void Form_Close(object sender, FormClosingEventArgs e)
{ {
Global.setFormWidth(this.Width); Global.setFormWidth(this.Width);
@ -170,55 +225,86 @@ namespace ScpServer
protected void ControllerStatusChanged() protected void ControllerStatusChanged()
{ {
// If controllers are detected, but not checked, automatically check #1 // If controllers are detected, but not checked, automatically check #1
bool checkFirst = true; //bool checkFirst = true;
bool optionsEnabled = false; String tooltip = "DS4Windows";
for (Int32 Index = 0; Index < Pad.Length; Index++) for (Int32 Index = 0; Index < Pads.Length; Index++)
{ {
Pad[Index].Text = rootHub.getDS4ControllerInfo(Index); Pads[Index].Text = rootHub.getDS4ControllerInfo(Index);
if (Pad[Index].Text != null && Pad[Index].Text != "") if (Pads[Index].Text != String.Empty)
{ {
Pad[Index].Enabled = true; Pads[Index].Enabled = true;
optionsEnabled = true; cbs[Index].Enabled = true;
ebns[Index].Enabled = true;
dbns[Index].Enabled = true;
protexts[Index].Enabled = true;
Global.LoadProfile(Index);
// As above // As above
if (checkFirst && (Pad[Index].Checked && Index != 0)) //if (checkFirst && (Pads[Index].Checked && Index != 0))
checkFirst = false; // checkFirst = false;
} }
else else
{ {
Pad[Index].Text = "Disconnected"; Pads[Index].Text = "Disconnected";
Pad[Index].Enabled = false; Pads[Index].Enabled = false;
Pad[Index].Checked = false; cbs[Index].Enabled = false;
ebns[Index].Enabled = false;
dbns[Index].Enabled = false;
protexts[Index].Enabled = false;
if (OptionsDialog[Index] != null)
OptionsDialog[Index].Close();
// As above // As above
if (Index == 0) //if (Index == 0)
checkFirst = false; // checkFirst = false;
} }
tooltip += "\n[" + (Index + 1) + "] " + rootHub.getShortDS4ControllerInfo(Index); // Carefully stay under the 63 character limit.
} }
btnClear.Enabled = lvDebug.Items.Count > 0; btnClear.Enabled = lvDebug.Items.Count > 0;
// As above // As above
if (checkFirst && btnClear.Enabled) //if (checkFirst && btnClear.Enabled)
Pad[0].Checked = true; // Pads[0].Checked = true;
optionsButton.Enabled = optionsEnabled; notifyIcon1.Text = tooltip;
} }
protected void On_Debug(object sender, DS4Control.DebugEventArgs e) protected void On_Debug(object sender, DS4Control.DebugEventArgs e)
{ {
LogDebug(e.Time, e.Data); LogDebug(e.Time, e.Data);
} }
private void optionsButton_Click(object sender, EventArgs e) private Options[] OptionsDialog = { null, null, null, null };
private void editButtons_Click(object sender, EventArgs e)
{ {
for (Int32 Index = 0; Index < Pad.Length; Index++) Button bn = (Button)sender;
int i = Int32.Parse(bn.Tag.ToString());
ComboBox[] cbs = { cBController1, cBController2, cBController3, cBController4 };
Options opt = OptionsDialog[i] = new Options(rootHub, i, cbs[i].Text, this);
opt.Text = "Options for Controller " + (i + 1);
opt.Icon = this.Icon;
opt.FormClosed += delegate
{ {
if (Pad[Index].Checked) OptionsDialog[i] = null;
{ dbns[i].Enabled = true;
Options opt = new Options(rootHub, Index); cbs[i].Enabled = true;
opt.Text = "Options for Controller " + (Index + 1); bn.Enabled = true;
opt.Icon = this.Icon; };
opt.ShowDialog(); opt.Show();
} cbs[i].Enabled = false;
dbns[i].Enabled = false;
bn.Enabled = false;
}
private void deleteButtons_Click(object sender, EventArgs e)
{
Button bn = (Button)sender;
int tdevice = Int32.Parse(bn.Tag.ToString());
string filename = cbs[tdevice].Items[cbs[tdevice].SelectedIndex].ToString();
if (MessageBox.Show("\"" + filename + "\" cannot be restored.", "Delete Profile?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
System.IO.File.Delete(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\" + filename + ".xml");
Global.setAProfile(tdevice, null);
RefreshProfiles();
} }
} }
private void notifyIcon_Click(object sender, EventArgs e) private void notifyIcon_Click(object sender, EventArgs e)
{ {
this.Show(); this.Show();
@ -266,6 +352,34 @@ namespace ScpServer
{ {
MessageBox.Show(((ListView)sender).FocusedItem.SubItems[1].Text,"Log"); MessageBox.Show(((ListView)sender).FocusedItem.SubItems[1].Text,"Log");
} }
private void Profile_Changed(object sender, EventArgs e)
{
ComboBox cb = (ComboBox)sender;
int tdevice = Int32.Parse(cb.Tag.ToString());
if (cb.Items[cb.Items.Count - 1].ToString() == "+New Profile")
{
if (cb.SelectedIndex < cb.Items.Count - 1)
{
Global.setAProfile(tdevice, cb.Items[cb.SelectedIndex].ToString());
Global.Save();
Global.LoadProfile(tdevice);
}
else if (cb.SelectedIndex == cb.Items.Count - 1 && cb.Items.Count > 1) //if +New Profile selected
{
Options opt = OptionsDialog[tdevice] = new Options(rootHub, tdevice, "", this);
opt.Text = "Options for Controller " + (tdevice + 1);
opt.Icon = this.Icon;
int i = tdevice;
opt.FormClosed += delegate { OptionsDialog[i] = null; };
opt.Show();
}
}
if (cb.Text == "")
ebns[tdevice].Text = "New";
else
ebns[tdevice].Text = "Edit";
}
} }
public class ThemeUtil public class ThemeUtil
@ -292,3 +406,4 @@ namespace ScpServer
} }
} }
} }


View File

@ -8,14 +8,6 @@ namespace HidLibrary
{ {
public class HidDevice : IDisposable public class HidDevice : IDisposable
{ {
public event InsertedEventHandler Inserted;
public event RemovedEventHandler Removed;
public event EventHandler<EventArgs> Remove;
public delegate void InsertedEventHandler();
public delegate void RemovedEventHandler();
public enum ReadStatus public enum ReadStatus
{ {
Success = 0, Success = 0,
@ -31,15 +23,10 @@ namespace HidLibrary
private readonly HidDeviceAttributes _deviceAttributes; private readonly HidDeviceAttributes _deviceAttributes;
private readonly HidDeviceCapabilities _deviceCapabilities; private readonly HidDeviceCapabilities _deviceCapabilities;
private readonly HidDeviceEventMonitor _deviceEventMonitor;
private byte idleTicks = 0;
private bool _monitorDeviceEvents; private bool _monitorDeviceEvents;
private string serial = null; private string serial = null;
internal HidDevice(string devicePath, string description = null) internal HidDevice(string devicePath, string description = null)
{ {
_deviceEventMonitor = new HidDeviceEventMonitor(this);
_deviceEventMonitor.Removed += DeviceEventMonitorRemoved;
_devicePath = devicePath; _devicePath = devicePath;
_description = description; _description = description;
@ -64,22 +51,11 @@ namespace HidLibrary
public bool IsOpen { get; private set; } public bool IsOpen { get; private set; }
public bool IsExclusive { get; private set; } public bool IsExclusive { get; private set; }
public bool IsConnected { get { return HidDevices.IsConnected(_devicePath); } } public bool IsConnected { get { return HidDevices.IsConnected(_devicePath); } }
public bool IsTimedOut { get { return idleTicks > 5; } }
public string Description { get { return _description; } } public string Description { get { return _description; } }
public HidDeviceCapabilities Capabilities { get { return _deviceCapabilities; } } public HidDeviceCapabilities Capabilities { get { return _deviceCapabilities; } }
public HidDeviceAttributes Attributes { get { return _deviceAttributes; } } public HidDeviceAttributes Attributes { get { return _deviceAttributes; } }
public string DevicePath { get { return _devicePath; } } public string DevicePath { get { return _devicePath; } }
public bool MonitorDeviceEvents
{
get { return _monitorDeviceEvents; }
set
{
if (value & _monitorDeviceEvents == false) _deviceEventMonitor.Init();
_monitorDeviceEvents = value;
}
}
public override string ToString() public override string ToString()
{ {
return string.Format("VendorID={0}, ProductID={1}, Version={2}, DevicePath={3}", return string.Format("VendorID={0}, ProductID={1}, Version={2}, DevicePath={3}",
@ -115,6 +91,18 @@ namespace HidLibrary
IsOpen = false; IsOpen = false;
} }
public void Dispose()
{
CancelIO();
CloseDevice();
}
public void CancelIO()
{
if (IsOpen)
NativeMethods.CancelIoEx(safeReadHandle.DangerousGetHandle(), IntPtr.Zero);
}
public bool ReadInputReport(byte[] data) public bool ReadInputReport(byte[] data)
{ {
if (safeReadHandle == null) if (safeReadHandle == null)
@ -159,44 +147,6 @@ namespace HidLibrary
safeReadHandle = null; safeReadHandle = null;
} }
private void DeviceEventMonitorInserted()
{
if (IsOpen) OpenDevice(false);
if (Inserted != null) Inserted();
}
private void DeviceEventMonitorRemoved()
{
if (IsOpen)
{
lock (this)
{
idleTicks = 100;
}
MonitorDeviceEvents = false;
Console.WriteLine("Cancelling IO");
NativeMethods.CancelIoEx(safeReadHandle.DangerousGetHandle(), IntPtr.Zero);
Console.WriteLine("Cancelled IO");
CloseDevice();
Console.WriteLine("Device is closed.");
}
if (Removed != null) Removed();
if (Remove != null) Remove(this, new EventArgs());
}
public void Tick()
{
lock (this)
{
idleTicks++;
}
}
public void Dispose()
{
if (MonitorDeviceEvents) MonitorDeviceEvents = false;
if (IsOpen) CloseDevice();
}
public void flush_Queue() public void flush_Queue()
{ {
if (safeReadHandle != null) if (safeReadHandle != null)
@ -230,10 +180,6 @@ namespace HidLibrary
try try
{ {
uint bytesRead; uint bytesRead;
lock (this)
{
idleTicks = 0;
}
if (NativeMethods.ReadFile(safeReadHandle.DangerousGetHandle(), inputBuffer, (uint)inputBuffer.Length, out bytesRead, IntPtr.Zero)) if (NativeMethods.ReadFile(safeReadHandle.DangerousGetHandle(), inputBuffer, (uint)inputBuffer.Length, out bytesRead, IntPtr.Zero))
{ {
return ReadStatus.Success; return ReadStatus.Success;

View File

@ -48,7 +48,6 @@
<Compile Include="HidDevice.cs" /> <Compile Include="HidDevice.cs" />
<Compile Include="HidDeviceAttributes.cs" /> <Compile Include="HidDeviceAttributes.cs" />
<Compile Include="HidDeviceCapabilities.cs" /> <Compile Include="HidDeviceCapabilities.cs" />
<Compile Include="HidDeviceEventMonitor.cs" />
<Compile Include="HidDevices.cs" /> <Compile Include="HidDevices.cs" />
<Compile Include="NativeMethods.cs" /> <Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />