Code clean up. Reset xinput mapping for more bound actions.

This commit is contained in:
Travis Nickles 2017-05-12 07:48:58 -07:00
parent f3c9e08398
commit edeaa30b59
14 changed files with 386 additions and 391 deletions

View File

@ -127,7 +127,6 @@ namespace DS4Windows
WarnExclusiveModeFailure(device); WarnExclusiveModeFailure(device);
DS4Controllers[i] = device; DS4Controllers[i] = device;
//device.Removal -= DS4Devices.On_Removal;
device.Removal += this.On_DS4Removal; device.Removal += this.On_DS4Removal;
device.Removal += DS4Devices.On_Removal; device.Removal += DS4Devices.On_Removal;
touchPad[i] = new Mouse(i, device); touchPad[i] = new Mouse(i, device);
@ -190,7 +189,6 @@ namespace DS4Windows
Log.LogToTray(logMessage); Log.LogToTray(logMessage);
} }
//ControllerStatusChanged(this);
runHotPlug = true; runHotPlug = true;
return true; return true;
@ -281,11 +279,6 @@ namespace DS4Windows
{ {
device.StopUpdate(); device.StopUpdate();
device.DisconnectBT(true); device.DisconnectBT(true);
/*Task temp = Task.Delay(50).ContinueWith((t) => {
while (!device.IsRemoved) { System.Threading.Thread.Sleep(10); }
});
temp.Wait(100);
*/
} }
} }
} }
@ -323,7 +316,6 @@ namespace DS4Windows
LogDebug(Properties.Resources.FoundController + device.getMacAddress() + " (" + device.getConnectionType() + ")"); LogDebug(Properties.Resources.FoundController + device.getMacAddress() + " (" + device.getConnectionType() + ")");
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;
device.Removal += DS4Devices.On_Removal; device.Removal += DS4Devices.On_Removal;
touchPad[Index] = new Mouse(Index, device); touchPad[Index] = new Mouse(Index, device);
@ -367,8 +359,6 @@ namespace DS4Windows
} }
} }
} }
//ControllerStatusChanged(this);
} }
return true; return true;
@ -551,7 +541,8 @@ namespace DS4Windows
public bool[] lag = { false, false, false, false }; public bool[] lag = { false, false, false, false };
public bool[] inWarnMonitor = { false, false, false, false }; public bool[] inWarnMonitor = { false, false, false, false };
//Called every time the new input report has arrived
//Called every time a new input report has arrived
protected virtual void On_Report(object sender, EventArgs e) protected virtual void On_Report(object sender, EventArgs e)
{ {
DS4Device device = (DS4Device)sender; DS4Device device = (DS4Device)sender;
@ -801,138 +792,6 @@ namespace DS4Windows
return result; return result;
} }
/* TODO: Not used. Possible candidate for removal. Currently keeping for reference. */
/*public DS4Controls GetInputkeysDS4(int ind)
{
DS4State cState = CurrentState[ind];
DS4StateExposed eState = ExposedState[ind];
Mouse tp = touchPad[ind];
DS4Controls result = DS4Controls.None;
if (DS4Controllers[ind] != null)
{
if (Mapping.getBoolButtonMapping(cState.Cross))
{
result = DS4Controls.Cross;
}
else if (Mapping.getBoolButtonMapping(cState.Circle))
{
result = DS4Controls.Circle;
}
else if (Mapping.getBoolButtonMapping(cState.Triangle))
{
result = DS4Controls.Triangle;
}
else if (Mapping.getBoolButtonMapping(cState.Square))
{
result = DS4Controls.Square;
}
else if (Mapping.getBoolButtonMapping(cState.L1))
{
result = DS4Controls.L1;
}
else if (Mapping.getBoolTriggerMapping(cState.L2))
{
result = DS4Controls.L2;
}
else if (Mapping.getBoolButtonMapping(cState.L3))
{
result = DS4Controls.L3;
}
else if (Mapping.getBoolButtonMapping(cState.R1))
{
result = DS4Controls.R1;
}
else if (Mapping.getBoolTriggerMapping(cState.R2))
{
result = DS4Controls.R2;
}
else if (Mapping.getBoolButtonMapping(cState.R3))
{
result = DS4Controls.R3;
}
else if (Mapping.getBoolButtonMapping(cState.DpadUp))
{
result = DS4Controls.DpadUp;
}
else if (Mapping.getBoolButtonMapping(cState.DpadDown))
{
result = DS4Controls.DpadDown;
}
else if (Mapping.getBoolButtonMapping(cState.DpadLeft))
{
result = DS4Controls.DpadLeft;
}
else if (Mapping.getBoolButtonMapping(cState.DpadRight))
{
result = DS4Controls.DpadRight;
}
else if (Mapping.getBoolButtonMapping(cState.Share))
{
result = DS4Controls.Share;
}
else if (Mapping.getBoolButtonMapping(cState.Options))
{
result = DS4Controls.Options;
}
else if (Mapping.getBoolButtonMapping(cState.PS))
{
result = DS4Controls.PS;
}
else if (Mapping.getBoolAxisDirMapping(cState.LX, true))
{
result = DS4Controls.LXPos;
}
else if (Mapping.getBoolAxisDirMapping(cState.LX, false))
{
result = DS4Controls.LXNeg;
}
else if (Mapping.getBoolAxisDirMapping(cState.LY, true))
{
result = DS4Controls.LYPos;
}
else if (Mapping.getBoolAxisDirMapping(cState.LY, false))
{
result = DS4Controls.LYNeg;
}
else if (Mapping.getBoolAxisDirMapping(cState.RX, true))
{
result = DS4Controls.RXPos;
}
else if (Mapping.getBoolAxisDirMapping(cState.RX, false))
{
result = DS4Controls.RXNeg;
}
else if (Mapping.getBoolAxisDirMapping(cState.RY, true))
{
result = DS4Controls.RYPos;
}
else if (Mapping.getBoolAxisDirMapping(cState.RY, false))
{
result = DS4Controls.RYNeg;
}
else if (Mapping.getBoolTouchMapping(tp.leftDown))
{
result = DS4Controls.TouchLeft;
}
else if (Mapping.getBoolTouchMapping(tp.rightDown))
{
result = DS4Controls.TouchRight;
}
else if (Mapping.getBoolTouchMapping(tp.multiDown))
{
result = DS4Controls.TouchMulti;
}
else if (Mapping.getBoolTouchMapping(tp.upperDown))
{
result = DS4Controls.TouchUpper;
}
}
return result;
}
*/
public bool[] touchreleased = { true, true, true, true }, touchslid = { false, false, false, false }; public bool[] touchreleased = { true, true, true, true }, touchslid = { false, false, false, false };
public byte[] oldtouchvalue = { 0, 0, 0, 0 }; public byte[] oldtouchvalue = { 0, 0, 0, 0 };
public int[] oldscrollvalue = { 0, 0, 0, 0 }; public int[] oldscrollvalue = { 0, 0, 0, 0 };

View File

@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing; using System.Drawing;
using static System.Math; using static System.Math;
using static DS4Windows.Global; using static DS4Windows.Global;

View File

@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DS4Windows namespace DS4Windows
{ {

View File

@ -886,13 +886,15 @@ namespace DS4Windows
bool active = getBoolMapping2(device, dcs.control, cState, eState, tp, fieldMapping); bool active = getBoolMapping2(device, dcs.control, cState, eState, tp, fieldMapping);
if (active) if (active)
{ {
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping);
PlayMacro(device, macroControl, string.Join("/", (int[])action), dcs.control, keyType); PlayMacro(device, macroControl, string.Join("/", (int[])action), dcs.control, keyType);
} }
else else
{ {
EndMacro(device, macroControl, string.Join("/", (int[])action), dcs.control); EndMacro(device, macroControl, string.Join("/", (int[])action), dcs.control);
} }
// erase default mappings for things that are remapped
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping);
} }
else if (actionType == DS4ControlSettings.ActionType.Key) else if (actionType == DS4ControlSettings.ActionType.Key)
{ {
@ -900,7 +902,6 @@ namespace DS4Windows
ushort value = Convert.ToUInt16(action); ushort value = Convert.ToUInt16(action);
if (getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping)) if (getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping))
{ {
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping);
SyntheticState.KeyPresses kp; SyntheticState.KeyPresses kp;
if (!deviceState.keyPresses.TryGetValue(value, out kp)) if (!deviceState.keyPresses.TryGetValue(value, out kp))
deviceState.keyPresses[value] = kp = new SyntheticState.KeyPresses(); deviceState.keyPresses[value] = kp = new SyntheticState.KeyPresses();
@ -923,6 +924,9 @@ namespace DS4Windows
} }
else else
pressedonce[value] = false; pressedonce[value] = false;
// erase default mappings for things that are remapped
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping);
} }
else if (actionType == DS4ControlSettings.ActionType.Button) else if (actionType == DS4ControlSettings.ActionType.Button)
{ {
@ -1096,7 +1100,8 @@ namespace DS4Windows
} }
} }
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping); // erase default mappings for things that are remapped // erase default mappings for things that are remapped
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping);
} }
} }
@ -3401,6 +3406,8 @@ namespace DS4Windows
else if (controlType == DS4StateFieldMapping.ControlType.AxisDir) else if (controlType == DS4StateFieldMapping.ControlType.AxisDir)
{ {
fieldMap.axisdirs[controlNum] = 127; fieldMap.axisdirs[controlNum] = 127;
int controlRelation = (controlNum % 2 == 0 ? controlNum - 1 : controlNum + 1);
fieldMap.axisdirs[controlRelation] = 127;
} }
else if (controlType == DS4StateFieldMapping.ControlType.Trigger) else if (controlType == DS4StateFieldMapping.ControlType.Trigger)
{ {

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace DS4Windows namespace DS4Windows
{ {

View File

@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DS4Windows namespace DS4Windows
{ {

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace DS4Windows namespace DS4Windows
{ {
[Flags] [Flags]
public enum DS4KeyType : byte { None = 0, ScanCode = 1, Toggle = 2, Unbound = 4, Macro = 8, HoldMacro = 16, RepeatMacro = 32 }; //Increment by exponents of 2*, starting at 2^0 public enum DS4KeyType : byte { None = 0, ScanCode = 1, Toggle = 2, Unbound = 4, Macro = 8, HoldMacro = 16, RepeatMacro = 32 }; // Increment by exponents of 2*, starting at 2^0
public enum Ds3PadId : byte { None = 0xFF, One = 0x00, Two = 0x01, Three = 0x02, Four = 0x03, All = 0x04 }; public enum Ds3PadId : byte { None = 0xFF, One = 0x00, Two = 0x01, Three = 0x02, Four = 0x03, All = 0x04 };
public enum DS4Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, L1, L2, L3, R1, R2, R3, Square, Triangle, Circle, Cross, DpadUp, DpadRight, DpadDown, DpadLeft, PS, TouchLeft, TouchUpper, TouchMulti, TouchRight, Share, Options, GyroXPos, GyroXNeg, GyroZPos, GyroZNeg, SwipeLeft, SwipeRight, SwipeUp, SwipeDown }; public enum DS4Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, L1, L2, L3, R1, R2, R3, Square, Triangle, Circle, Cross, DpadUp, DpadRight, DpadDown, DpadLeft, PS, TouchLeft, TouchUpper, TouchMulti, TouchRight, Share, Options, GyroXPos, GyroXNeg, GyroZPos, GyroZNeg, SwipeLeft, SwipeRight, SwipeUp, SwipeDown };
public enum X360Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, LB, LT, LS, RB, RT, RS, X, Y, B, A, DpadUp, DpadRight, DpadDown, DpadLeft, Guide, Back, Start, LeftMouse, RightMouse, MiddleMouse, FourthMouse, FifthMouse, WUP, WDOWN, MouseUp, MouseDown, MouseLeft, MouseRight, Unbound }; public enum X360Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, LB, LT, LS, RB, RT, RS, X, Y, B, A, DpadUp, DpadRight, DpadDown, DpadLeft, Guide, Back, Start, LeftMouse, RightMouse, MiddleMouse, FourthMouse, FifthMouse, WUP, WDOWN, MouseUp, MouseDown, MouseLeft, MouseRight, Unbound };
@ -231,6 +231,7 @@ namespace DS4Windows
X360Controls.None, X360Controls.None, X360Controls.None, X360Controls.None X360Controls.None, X360Controls.None, X360Controls.None, X360Controls.None
}; };
// Create mapping array at runtime
public static DS4Controls[] reverseX360ButtonMapping = new Func<DS4Controls[]>(() => public static DS4Controls[] reverseX360ButtonMapping = new Func<DS4Controls[]>(() =>
{ {
DS4Controls[] temp = new DS4Controls[defaultButtonMapping.Length]; DS4Controls[] temp = new DS4Controls[defaultButtonMapping.Length];
@ -252,6 +253,7 @@ namespace DS4Windows
m_Config.m_Profile = appdatapath + "\\Profiles.xml"; m_Config.m_Profile = appdatapath + "\\Profiles.xml";
m_Config.m_Actions = appdatapath + "\\Actions.xml"; m_Config.m_Actions = appdatapath + "\\Actions.xml";
} }
/// <summary> /// <summary>
/// Check if Admin Rights are needed to write in Appliplation Directory /// Check if Admin Rights are needed to write in Appliplation Directory
/// </summary> /// </summary>
@ -320,6 +322,7 @@ namespace DS4Windows
set { m_Config.useExclusiveMode = value; } set { m_Config.useExclusiveMode = value; }
get { return m_Config.useExclusiveMode; } get { return m_Config.useExclusiveMode; }
} }
public static bool getUseExclusiveMode() public static bool getUseExclusiveMode()
{ {
return m_Config.useExclusiveMode; return m_Config.useExclusiveMode;
@ -336,83 +339,100 @@ namespace DS4Windows
set { m_Config.CheckWhen = value; } set { m_Config.CheckWhen = value; }
get { return m_Config.CheckWhen; } get { return m_Config.CheckWhen; }
} }
public static int Notifications public static int Notifications
{ {
set { m_Config.notifications = value; } set { m_Config.notifications = value; }
get { return m_Config.notifications; } get { return m_Config.notifications; }
} }
public static bool DCBTatStop public static bool DCBTatStop
{ {
set { m_Config.disconnectBTAtStop = value; } set { m_Config.disconnectBTAtStop = value; }
get { return m_Config.disconnectBTAtStop; } get { return m_Config.disconnectBTAtStop; }
} }
public static bool SwipeProfiles public static bool SwipeProfiles
{ {
set { m_Config.swipeProfiles = value; } set { m_Config.swipeProfiles = value; }
get { return m_Config.swipeProfiles; } get { return m_Config.swipeProfiles; }
} }
public static bool DS4Mapping public static bool DS4Mapping
{ {
set { m_Config.ds4Mapping = value; } set { m_Config.ds4Mapping = value; }
get { return m_Config.ds4Mapping; } get { return m_Config.ds4Mapping; }
} }
public static bool QuickCharge public static bool QuickCharge
{ {
set { m_Config.quickCharge = value; } set { m_Config.quickCharge = value; }
get { return m_Config.quickCharge; } get { return m_Config.quickCharge; }
} }
public static bool getQuickCharge() public static bool getQuickCharge()
{ {
return m_Config.quickCharge; return m_Config.quickCharge;
} }
public static int FirstXinputPort public static int FirstXinputPort
{ {
set { m_Config.firstXinputPort = value; } set { m_Config.firstXinputPort = value; }
get { return m_Config.firstXinputPort; } get { return m_Config.firstXinputPort; }
} }
public static bool CloseMini public static bool CloseMini
{ {
set { m_Config.closeMini = value; } set { m_Config.closeMini = value; }
get { return m_Config.closeMini; } get { return m_Config.closeMini; }
} }
public static bool StartMinimized public static bool StartMinimized
{ {
set { m_Config.startMinimized = value; } set { m_Config.startMinimized = value; }
get { return m_Config.startMinimized; } get { return m_Config.startMinimized; }
} }
public static int FormWidth public static int FormWidth
{ {
set { m_Config.formWidth = value; } set { m_Config.formWidth = value; }
get { return m_Config.formWidth;} get { return m_Config.formWidth;}
} }
public static int FormHeight public static int FormHeight
{ {
set { m_Config.formHeight = value; } set { m_Config.formHeight = value; }
get { return m_Config.formHeight; } get { return m_Config.formHeight; }
} }
public static bool DownloadLang public static bool DownloadLang
{ {
set { m_Config.downloadLang = value; } set { m_Config.downloadLang = value; }
get { return m_Config.downloadLang; } get { return m_Config.downloadLang; }
} }
public static bool FlashWhenLate public static bool FlashWhenLate
{ {
set { m_Config.flashWhenLate = value; } set { m_Config.flashWhenLate = value; }
get { return m_Config.flashWhenLate; } get { return m_Config.flashWhenLate; }
} }
public static bool getFlashWhenLate() public static bool getFlashWhenLate()
{ {
return m_Config.flashWhenLate; return m_Config.flashWhenLate;
} }
public static int FlashWhenLateAt public static int FlashWhenLateAt
{ {
set { m_Config.flashWhenLateAt = value; } set { m_Config.flashWhenLateAt = value; }
get { return m_Config.flashWhenLateAt; } get { return m_Config.flashWhenLateAt; }
} }
public static int getFlashWhenLateAt() public static int getFlashWhenLateAt()
{ {
return m_Config.flashWhenLateAt; return m_Config.flashWhenLateAt;
} }
public static bool UseWhiteIcon public static bool UseWhiteIcon
{ {
set { m_Config.useWhiteIcon = value; } set { m_Config.useWhiteIcon = value; }
@ -421,40 +441,48 @@ namespace DS4Windows
// controller/profile specfic values // controller/profile specfic values
public static int[] ButtonMouseSensitivity => m_Config.buttonMouseSensitivity; public static int[] ButtonMouseSensitivity => m_Config.buttonMouseSensitivity;
public static byte[] RumbleBoost => m_Config.rumble; public static byte[] RumbleBoost => m_Config.rumble;
public static byte getRumbleBoost(int index) public static byte getRumbleBoost(int index)
{ {
return m_Config.rumble[index]; return m_Config.rumble[index];
} }
public static double[] Rainbow => m_Config.rainbow; public static double[] Rainbow => m_Config.rainbow;
public static double getRainbow(int index) public static double getRainbow(int index)
{ {
return m_Config.rainbow[index]; return m_Config.rainbow[index];
} }
public static bool[] FlushHIDQueue => m_Config.flushHIDQueue; public static bool[] FlushHIDQueue => m_Config.flushHIDQueue;
public static bool getFlushHIDQueue(int index) public static bool getFlushHIDQueue(int index)
{ {
return m_Config.flushHIDQueue[index]; return m_Config.flushHIDQueue[index];
} }
public static bool[] EnableTouchToggle => m_Config.enableTouchToggle; public static bool[] EnableTouchToggle => m_Config.enableTouchToggle;
public static bool getEnableTouchToggle(int index) public static bool getEnableTouchToggle(int index)
{ {
return m_Config.enableTouchToggle[index]; return m_Config.enableTouchToggle[index];
} }
public static int[] IdleDisconnectTimeout => m_Config.idleDisconnectTimeout; public static int[] IdleDisconnectTimeout => m_Config.idleDisconnectTimeout;
public static int getIdleDisconnectTimeout(int index) public static int getIdleDisconnectTimeout(int index)
{ {
return m_Config.idleDisconnectTimeout[index]; return m_Config.idleDisconnectTimeout[index];
} }
public static byte[] TouchSensitivity => m_Config.touchSensitivity; public static byte[] TouchSensitivity => m_Config.touchSensitivity;
public static byte[] getTouchSensitivity() public static byte[] getTouchSensitivity()
{ {
return m_Config.touchSensitivity; return m_Config.touchSensitivity;
} }
public static byte getTouchSensitivity(int index) public static byte getTouchSensitivity(int index)
{ {
return m_Config.touchSensitivity[index]; return m_Config.touchSensitivity[index];
} }
public static byte[] FlashType => m_Config.flashType; public static byte[] FlashType => m_Config.flashType;
public static byte getFlashType(int index) public static byte getFlashType(int index)
{ {
@ -472,51 +500,61 @@ namespace DS4Windows
{ {
return m_Config.ledAsBattery[index]; return m_Config.ledAsBattery[index];
} }
public static int[] ChargingType => m_Config.chargingType; public static int[] ChargingType => m_Config.chargingType;
public static int getChargingType(int index) public static int getChargingType(int index)
{ {
return m_Config.chargingType[index]; return m_Config.chargingType[index];
} }
public static bool[] DinputOnly => m_Config.dinputOnly; public static bool[] DinputOnly => m_Config.dinputOnly;
public static bool getDInputOnly(int index) public static bool getDInputOnly(int index)
{ {
return m_Config.dinputOnly[index]; return m_Config.dinputOnly[index];
} }
public static bool[] StartTouchpadOff => m_Config.startTouchpadOff; public static bool[] StartTouchpadOff => m_Config.startTouchpadOff;
public static bool[] UseTPforControls => m_Config.useTPforControls; public static bool[] UseTPforControls => m_Config.useTPforControls;
public static bool getUseTPforControls(int index) public static bool getUseTPforControls(int index)
{ {
return m_Config.useTPforControls[index]; return m_Config.useTPforControls[index];
} }
public static bool[] UseSAforMouse => m_Config.useSAforMouse; public static bool[] UseSAforMouse => m_Config.useSAforMouse;
public static bool isUsingSAforMouse(int index) public static bool isUsingSAforMouse(int index)
{ {
return m_Config.useSAforMouse[index]; return m_Config.useSAforMouse[index];
} }
public static string[] SATriggers => m_Config.sATriggers; public static string[] SATriggers => m_Config.sATriggers;
public static int[] GyroSensitivity => m_Config.gyroSensitivity; public static int[] GyroSensitivity => m_Config.gyroSensitivity;
public static int[] GyroInvert => m_Config.gyroInvert; public static int[] GyroInvert => m_Config.gyroInvert;
public static DS4Color[] MainColor => m_Config.m_Leds; public static DS4Color[] MainColor => m_Config.m_Leds;
public static DS4Color getMainColor(int index) public static DS4Color getMainColor(int index)
{ {
return m_Config.m_Leds[index]; return m_Config.m_Leds[index];
} }
public static DS4Color[] LowColor => m_Config.m_LowLeds; public static DS4Color[] LowColor => m_Config.m_LowLeds;
public static DS4Color getLowColor(int index) public static DS4Color getLowColor(int index)
{ {
return m_Config.m_LowLeds[index]; return m_Config.m_LowLeds[index];
} }
public static DS4Color[] ChargingColor => m_Config.m_ChargingLeds; public static DS4Color[] ChargingColor => m_Config.m_ChargingLeds;
public static DS4Color getChargingColor(int index) public static DS4Color getChargingColor(int index)
{ {
return m_Config.m_ChargingLeds[index]; return m_Config.m_ChargingLeds[index];
} }
public static DS4Color[] CustomColor => m_Config.m_CustomLeds; public static DS4Color[] CustomColor => m_Config.m_CustomLeds;
public static DS4Color getCustomColor(int index) public static DS4Color getCustomColor(int index)
{ {
return m_Config.m_CustomLeds[index]; return m_Config.m_CustomLeds[index];
} }
public static bool[] UseCustomLed => m_Config.useCustomLeds; public static bool[] UseCustomLed => m_Config.useCustomLeds;
public static bool getUseCustomLed(int index) public static bool getUseCustomLed(int index)
{ {
@ -528,8 +566,10 @@ namespace DS4Windows
{ {
return m_Config.m_FlashLeds[index]; return m_Config.m_FlashLeds[index];
} }
public static byte[] TapSensitivity => m_Config.tapSensitivity; public static byte[] TapSensitivity => m_Config.tapSensitivity;
public static bool[] DoubleTap => m_Config.doubleTap; public static bool[] DoubleTap => m_Config.doubleTap;
public static int[] ScrollSensitivity => m_Config.scrollSensitivity; public static int[] ScrollSensitivity => m_Config.scrollSensitivity;
public static int[] getScrollSensitivity() public static int[] getScrollSensitivity()
{ {
@ -548,128 +588,154 @@ namespace DS4Windows
{ {
return m_Config.l2Deadzone[index]; return m_Config.l2Deadzone[index];
} }
public static byte[] R2Deadzone => m_Config.r2Deadzone; public static byte[] R2Deadzone => m_Config.r2Deadzone;
public static byte getR2Deadzone(int index) public static byte getR2Deadzone(int index)
{ {
return m_Config.r2Deadzone[index]; return m_Config.r2Deadzone[index];
} }
public static double[] SXDeadzone => m_Config.SXDeadzone; public static double[] SXDeadzone => m_Config.SXDeadzone;
public static double getSXDeadzone(int index) public static double getSXDeadzone(int index)
{ {
return m_Config.SXDeadzone[index]; return m_Config.SXDeadzone[index];
} }
public static double[] SZDeadzone => m_Config.SZDeadzone; public static double[] SZDeadzone => m_Config.SZDeadzone;
public static double getSZDeadzone(int index) public static double getSZDeadzone(int index)
{ {
return m_Config.SZDeadzone[index]; return m_Config.SZDeadzone[index];
} }
public static int[] LSDeadzone => m_Config.LSDeadzone; public static int[] LSDeadzone => m_Config.LSDeadzone;
public static int getLSDeadzone(int index) public static int getLSDeadzone(int index)
{ {
return m_Config.LSDeadzone[index]; return m_Config.LSDeadzone[index];
} }
public static int[] RSDeadzone => m_Config.RSDeadzone; public static int[] RSDeadzone => m_Config.RSDeadzone;
public static int getRSDeadzone(int index) public static int getRSDeadzone(int index)
{ {
return m_Config.RSDeadzone[index]; return m_Config.RSDeadzone[index];
} }
public static int[] LSAntiDeadzone => m_Config.LSAntiDeadzone; public static int[] LSAntiDeadzone => m_Config.LSAntiDeadzone;
public static int getLSAntiDeadzone(int index) public static int getLSAntiDeadzone(int index)
{ {
return m_Config.LSAntiDeadzone[index]; return m_Config.LSAntiDeadzone[index];
} }
public static int[] RSAntiDeadzone => m_Config.RSAntiDeadzone; public static int[] RSAntiDeadzone => m_Config.RSAntiDeadzone;
public static int getRSAntiDeadzone(int index) public static int getRSAntiDeadzone(int index)
{ {
return m_Config.RSAntiDeadzone[index]; return m_Config.RSAntiDeadzone[index];
} }
public static int[] LSMaxzone => m_Config.LSMaxzone; public static int[] LSMaxzone => m_Config.LSMaxzone;
public static int getLSMaxzone(int index) public static int getLSMaxzone(int index)
{ {
return m_Config.LSMaxzone[index]; return m_Config.LSMaxzone[index];
} }
public static int[] RSMaxzone => m_Config.RSMaxzone; public static int[] RSMaxzone => m_Config.RSMaxzone;
public static int getRSMaxzone(int index) public static int getRSMaxzone(int index)
{ {
return m_Config.RSMaxzone[index]; return m_Config.RSMaxzone[index];
} }
public static int[] L2AntiDeadzone => m_Config.l2AntiDeadzone; public static int[] L2AntiDeadzone => m_Config.l2AntiDeadzone;
public static int getL2AntiDeadzone(int index) public static int getL2AntiDeadzone(int index)
{ {
return m_Config.l2AntiDeadzone[index]; return m_Config.l2AntiDeadzone[index];
} }
public static int[] R2AntiDeadzone => m_Config.r2AntiDeadzone; public static int[] R2AntiDeadzone => m_Config.r2AntiDeadzone;
public static int getR2AntiDeadzone(int index) public static int getR2AntiDeadzone(int index)
{ {
return m_Config.r2AntiDeadzone[index]; return m_Config.r2AntiDeadzone[index];
} }
public static int[] L2Maxzone => m_Config.l2Maxzone; public static int[] L2Maxzone => m_Config.l2Maxzone;
public static int getL2Maxzone(int index) public static int getL2Maxzone(int index)
{ {
return m_Config.l2Maxzone[index]; return m_Config.l2Maxzone[index];
} }
public static int[] R2Maxzone => m_Config.r2Maxzone; public static int[] R2Maxzone => m_Config.r2Maxzone;
public static int getR2Maxzone(int index) public static int getR2Maxzone(int index)
{ {
return m_Config.r2Maxzone[index]; return m_Config.r2Maxzone[index];
} }
public static int[] LSCurve => m_Config.lsCurve; public static int[] LSCurve => m_Config.lsCurve;
public static int getLSCurve(int index) public static int getLSCurve(int index)
{ {
return m_Config.lsCurve[index]; return m_Config.lsCurve[index];
} }
public static int[] RSCurve => m_Config.rsCurve; public static int[] RSCurve => m_Config.rsCurve;
public static int getRSCurve(int index) public static int getRSCurve(int index)
{ {
return m_Config.rsCurve[index]; return m_Config.rsCurve[index];
} }
public static double[] L2Sens => m_Config.l2Sens; public static double[] L2Sens => m_Config.l2Sens;
public static double getL2Sens(int index) public static double getL2Sens(int index)
{ {
return m_Config.l2Sens[index]; return m_Config.l2Sens[index];
} }
public static double[] R2Sens => m_Config.r2Sens; public static double[] R2Sens => m_Config.r2Sens;
public static double getR2Sens(int index) public static double getR2Sens(int index)
{ {
return m_Config.r2Sens[index]; return m_Config.r2Sens[index];
} }
public static double[] SXSens => m_Config.SXSens; public static double[] SXSens => m_Config.SXSens;
public static double getSXSens(int index) public static double getSXSens(int index)
{ {
return m_Config.SXSens[index]; return m_Config.SXSens[index];
} }
public static double[] SZSens => m_Config.SZSens; public static double[] SZSens => m_Config.SZSens;
public static double getSZSens(int index) public static double getSZSens(int index)
{ {
return m_Config.SZSens[index]; return m_Config.SZSens[index];
} }
public static double[] LSSens => m_Config.LSSens; public static double[] LSSens => m_Config.LSSens;
public static double getLSSens(int index) public static double getLSSens(int index)
{ {
return m_Config.LSSens[index]; return m_Config.LSSens[index];
} }
public static double[] RSSens => m_Config.RSSens; public static double[] RSSens => m_Config.RSSens;
public static double getRSSens(int index) public static double getRSSens(int index)
{ {
return m_Config.RSSens[index]; return m_Config.RSSens[index];
} }
public static bool[] MouseAccel => m_Config.mouseAccel; public static bool[] MouseAccel => m_Config.mouseAccel;
public static bool getMouseAccel(int device) public static bool getMouseAccel(int device)
{ {
return m_Config.mouseAccel[device]; return m_Config.mouseAccel[device];
} }
public static string[] LaunchProgram => m_Config.launchProgram; public static string[] LaunchProgram => m_Config.launchProgram;
public static string[] ProfilePath => m_Config.profilePath; public static string[] ProfilePath => m_Config.profilePath;
public static bool[] DistanceProfiles = m_Config.distanceProfiles; public static bool[] DistanceProfiles = m_Config.distanceProfiles;
public static List<string>[] ProfileActions => m_Config.profileActions; public static List<string>[] ProfileActions => m_Config.profileActions;
public static int getProfileActionCount(int index) public static int getProfileActionCount(int index)
{ {
return m_Config.profileActionCount[index]; return m_Config.profileActionCount[index];
} }
public static void calculateProfileActionCount(int index) public static void calculateProfileActionCount(int index)
{ {
m_Config.profileActionCount[index] = m_Config.profileActions[index].Count; m_Config.profileActionCount[index] = m_Config.profileActions[index].Count;
} }
public static List<string> getProfileActions(int index) public static List<string> getProfileActions(int index)
{ {
return m_Config.profileActions[index]; return m_Config.profileActions[index];
@ -681,6 +747,7 @@ namespace DS4Windows
m_Config.containsCustomAction[deviceNum] = m_Config.HasCustomActions(deviceNum); m_Config.containsCustomAction[deviceNum] = m_Config.HasCustomActions(deviceNum);
m_Config.containsCustomExtras[deviceNum] = m_Config.HasCustomExtras(deviceNum); m_Config.containsCustomExtras[deviceNum] = m_Config.HasCustomExtras(deviceNum);
} }
public static void UpdateDS4Extra(int deviceNum, string buttonName, bool shift, string exts) public static void UpdateDS4Extra(int deviceNum, string buttonName, bool shift, string exts)
{ {
m_Config.UpdateDS4CExtra(deviceNum, buttonName, shift, exts); m_Config.UpdateDS4CExtra(deviceNum, buttonName, shift, exts);
@ -699,10 +766,12 @@ namespace DS4Windows
public static DS4ControlSettings getDS4CSetting(int deviceNum, DS4Controls control) => m_Config.getDS4CSetting(deviceNum, control); public static DS4ControlSettings getDS4CSetting(int deviceNum, DS4Controls control) => m_Config.getDS4CSetting(deviceNum, control);
public static bool HasCustomActions(int deviceNum) => m_Config.HasCustomActions(deviceNum); public static bool HasCustomActions(int deviceNum) => m_Config.HasCustomActions(deviceNum);
public static bool HasCustomExtras(int deviceNum) => m_Config.HasCustomExtras(deviceNum); public static bool HasCustomExtras(int deviceNum) => m_Config.HasCustomExtras(deviceNum);
public static bool containsCustomAction(int deviceNum) public static bool containsCustomAction(int deviceNum)
{ {
return m_Config.containsCustomAction[deviceNum]; return m_Config.containsCustomAction[deviceNum];
} }
public static bool containsCustomExtras(int deviceNum) public static bool containsCustomExtras(int deviceNum)
{ {
return m_Config.containsCustomExtras[deviceNum]; return m_Config.containsCustomExtras[deviceNum];
@ -744,8 +813,11 @@ namespace DS4Windows
public static SpecialAction GetAction(string name) public static SpecialAction GetAction(string name)
{ {
foreach (SpecialAction sA in m_Config.actions) foreach (SpecialAction sA in m_Config.actions)
{
if (sA.name == name) if (sA.name == name)
return sA; return sA;
}
return new SpecialAction("null", "null", "null", "null"); return new SpecialAction("null", "null", "null", "null");
} }
@ -3063,6 +3135,7 @@ namespace DS4Windows
public string extra; public string extra;
public bool pressRelease = false; public bool pressRelease = false;
public DS4KeyType keyType; public DS4KeyType keyType;
public SpecialAction(string name, string controls, string type, string details, double delay = 0, string extras = "") public SpecialAction(string name, string controls, string type, string details, double delay = 0, string extras = "")
{ {
this.name = name; this.name = name;

View File

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace DS4Windows namespace DS4Windows
@ -25,7 +21,7 @@ namespace DS4Windows
bool loading = true; bool loading = true;
private int alphacolor; private int alphacolor;
private Color reg, full; private Color reg, full;
int bgc = 240; //Color of the form background, If greyscale color int bgc = 240; // Color of the form background, If greyscale color
private bool extraChanged; private bool extraChanged;
public KBM360(int deviceNum, Options ooo, Button buton) public KBM360(int deviceNum, Options ooo, Button buton)
@ -46,13 +42,22 @@ namespace DS4Windows
btnDefault.Text = Properties.Resources.FallBack; btnDefault.Text = Properties.Resources.FallBack;
} }
else if (button.Name.StartsWith("bn")) else if (button.Name.StartsWith("bn"))
{
Text = Properties.Resources.SelectActionTitle.Replace("*action*", button.Name.Substring(2)); Text = Properties.Resources.SelectActionTitle.Replace("*action*", button.Name.Substring(2));
}
foreach (Control control in Controls) foreach (Control control in Controls)
{
if (control is Button) if (control is Button)
((Button)control).Click += anybtn_Click; ((Button)control).Click += anybtn_Click;
}
foreach (Control control in pnl360Controls.Controls) foreach (Control control in pnl360Controls.Controls)
{
if (control is Button) if (control is Button)
((Button)control).Click += anybtn_Click; ((Button)control).Click += anybtn_Click;
}
if (button.Name.Contains("Touch") || button.Name.Contains("Swipe")) if (button.Name.Contains("Touch") || button.Name.Contains("Swipe"))
{ {
btnMOUSEDOWN.Visible = false; btnMOUSEDOWN.Visible = false;
@ -60,6 +65,7 @@ namespace DS4Windows
btnMOUSERIGHT.Visible = false; btnMOUSERIGHT.Visible = false;
btnMOUSEUP.Visible = false; btnMOUSEUP.Visible = false;
} }
ActiveControl = lBMacroOn; ActiveControl = lBMacroOn;
guideText = btnGuide.Text; guideText = btnGuide.Text;
btnGuide.Text = ""; btnGuide.Text = "";
@ -74,7 +80,9 @@ namespace DS4Windows
InitializeComponent(); InitializeComponent();
sA = ooo; sA = ooo;
button = buton; button = buton;
Size = new Size(btnVolUp.Location.X + btnVolUp.Size.Width * 2, btnNUMENTER.Location.Y + btnNUMENTER.Size.Height * 2); Size = new Size(btnVolUp.Location.X + btnVolUp.Size.Width * 2,
btnNUMENTER.Location.Y + btnNUMENTER.Size.Height * 2);
if (extras) if (extras)
{ {
cBScanCode.Checked = button.Text.Contains("(SC)"); cBScanCode.Checked = button.Text.Contains("(SC)");
@ -85,13 +93,17 @@ namespace DS4Windows
cBScanCode.Visible = false; cBScanCode.Visible = false;
cBToggle.Visible = false; cBToggle.Visible = false;
} }
gBExtras.Visible = false; gBExtras.Visible = false;
bnMacro.Visible = false; bnMacro.Visible = false;
X360Label.Visible = false; X360Label.Visible = false;
Text = Properties.Resources.SelectActionTitle.Replace("*action*", "Trigger"); Text = Properties.Resources.SelectActionTitle.Replace("*action*", "Trigger");
foreach (Control control in Controls) foreach (Control control in Controls)
{
if (control is Button) if (control is Button)
((Button)control).Click += anybtn_Click; ((Button)control).Click += anybtn_Click;
}
btnMOUSEDOWN.Visible = false; btnMOUSEDOWN.Visible = false;
btnMOUSELEFT.Visible = false; btnMOUSELEFT.Visible = false;
btnMOUSERIGHT.Visible = false; btnMOUSERIGHT.Visible = false;
@ -130,20 +142,21 @@ namespace DS4Windows
keyname = "How did you get here?"; keyname = "How did you get here?";
} }
else */ else */
if (((Button)sender).Tag == null) if (bn.Tag == null)
keyname = ((Button)sender).Text; keyname = bn.Text;
else if (((Button)sender).Tag.ToString().Contains("X360")) else if (bn.Tag.ToString().Contains("X360"))
keyname = ((Button)sender).Tag.ToString().Substring(4); keyname = bn.Tag.ToString().Substring(4);
else if (((Button)sender).Tag != null && ushort.TryParse(((Button)sender).Tag.ToString(), out val)) else if (bn.Tag != null && ushort.TryParse(bn.Tag.ToString(), out val))
keyname = ((Keys)val).ToString(); keyname = ((Keys)val).ToString();
else else
keyname = ((Button)sender).Tag.ToString(); keyname = bn.Tag.ToString();
object keytag; object keytag;
//ushort val; //ushort val;
if (((Button)sender).Tag != null && ((Button)sender).Tag.ToString().Contains("X360")) if (bn.Tag != null && bn.Tag.ToString().Contains("X360"))
{ {
//keytag = ((Button)sender).Tag.ToString().Substring(4); //keytag = ((Button)sender).Tag.ToString().Substring(4);
keytag = Global.getX360ControlsByName(((Button)sender).Tag.ToString().Substring(4)); keytag = Global.getX360ControlsByName(bn.Tag.ToString().Substring(4));
DS4Controls psButton = Global.getDS4ControlsByName(button.Name); DS4Controls psButton = Global.getDS4ControlsByName(button.Name);
if ((X360Controls)keytag == Global.getDefaultX360ControlBinding(psButton) && if ((X360Controls)keytag == Global.getDefaultX360ControlBinding(psButton) &&
!cBScanCode.Checked && !cBToggle.Checked && !rBShiftModifer.Checked) !cBScanCode.Checked && !cBToggle.Checked && !rBShiftModifer.Checked)
@ -152,10 +165,10 @@ namespace DS4Windows
keytag = null; keytag = null;
} }
} }
else if (((Button)sender).Tag != null && ushort.TryParse(((Button)sender).Tag.ToString(), out val)) else if (bn.Tag != null && ushort.TryParse(bn.Tag.ToString(), out val))
keytag = val; keytag = val;
else else
keytag = ((Button)sender).Tag; keytag = bn.Tag;
lBMacroOn.Visible = false; lBMacroOn.Visible = false;
string extras = GetExtras(); string extras = GetExtras();
@ -166,13 +179,18 @@ namespace DS4Windows
bool scanavail = tagisint; bool scanavail = tagisint;
bool toggleavil = tagisint; bool toggleavil = tagisint;
if (ops != null) if (ops != null)
ops.ChangeButtonText(button, rBShiftModifer.Checked, tag, (scanavail ? cBScanCode.Checked : false), (toggleavil ? cBToggle.Checked : false), false, false, cBShiftButton.SelectedIndex); {
ops.ChangeButtonText(button, rBShiftModifer.Checked, tag,
(scanavail ? cBScanCode.Checked : false), (toggleavil ? cBToggle.Checked : false),
false, false, cBShiftButton.SelectedIndex);
}
else if (sA != null) else if (sA != null)
{ {
button.Text = keyname; button.Text = keyname;
button.Tag = keytag; button.Tag = keytag;
button.ForeColor = Color.Black; button.ForeColor = Color.Black;
} }
this.Close(); this.Close();
} }
} }
@ -182,6 +200,7 @@ namespace DS4Windows
string t =(byte)nUDHeavy.Value + "," + (byte)nUDLight.Value + "," + string t =(byte)nUDHeavy.Value + "," + (byte)nUDLight.Value + "," +
(cBLightbar.Checked ? "1" + "," + tBRedBar.Value + "," + tBGreenBar.Value + "," + tBBlueBar.Value + "," + nUDLightFlash.Value: "0,0,0,0,0") + "," + (cBLightbar.Checked ? "1" + "," + tBRedBar.Value + "," + tBGreenBar.Value + "," + tBBlueBar.Value + "," + nUDLightFlash.Value: "0,0,0,0,0") + "," +
(cBMouse.Checked ? "1" + "," + (byte)nUDMouse.Value : "0,0"); (cBMouse.Checked ? "1" + "," + (byte)nUDMouse.Value : "0,0");
return t; return t;
} }
@ -243,13 +262,17 @@ namespace DS4Windows
KeyValuePair<object, string> tag = new KeyValuePair<object, string>(e.KeyValue, extras); KeyValuePair<object, string> tag = new KeyValuePair<object, string>(e.KeyValue, extras);
newaction = true; newaction = true;
if (ops != null) if (ops != null)
ops.ChangeButtonText(button, rBShiftModifer.Checked, tag, cBScanCode.Checked, cBToggle.Checked, false, false, cBShiftButton.SelectedIndex); {
ops.ChangeButtonText(button, rBShiftModifer.Checked, tag,
cBScanCode.Checked, cBToggle.Checked, false, false, cBShiftButton.SelectedIndex);
}
else if (sA != null) else if (sA != null)
{ {
button.Text = e.KeyCode.ToString(); button.Text = e.KeyCode.ToString();
button.Tag = e.KeyValue; button.Tag = e.KeyValue;
button.ForeColor = Color.Black; button.ForeColor = Color.Black;
} }
this.Close(); this.Close();
} }
} }
@ -263,22 +286,21 @@ namespace DS4Windows
KeyValuePair<object, string> tag = new KeyValuePair<object, string>(e.KeyValue, extras); KeyValuePair<object, string> tag = new KeyValuePair<object, string>(e.KeyValue, extras);
newaction = true; newaction = true;
if (ops != null) if (ops != null)
ops.ChangeButtonText(button, rBShiftModifer.Checked, tag, cBScanCode.Checked, cBToggle.Checked, false, false, cBShiftButton.SelectedIndex); {
ops.ChangeButtonText(button, rBShiftModifer.Checked, tag,
cBScanCode.Checked, cBToggle.Checked, false, false, cBShiftButton.SelectedIndex);
}
else if (sA != null) else if (sA != null)
{ {
button.Text = e.KeyCode.ToString(); button.Text = e.KeyCode.ToString();
button.Tag = e.KeyValue; button.Tag = e.KeyValue;
button.ForeColor = Color.Black; button.ForeColor = Color.Black;
} }
this.Close(); this.Close();
} }
} }
private void cbToggle_CheckedChanged(object sender, EventArgs e)
{
}
private void btnMacro_Click(object sender, EventArgs e) private void btnMacro_Click(object sender, EventArgs e)
{ {
gBExtras.Controls.Add(cBScanCode); gBExtras.Controls.Add(cBScanCode);
@ -301,11 +323,14 @@ namespace DS4Windows
case Keys.Up: case Keys.Up:
case Keys.Down: case Keys.Down:
return true; return true;
case Keys.Shift | Keys.Right:
case Keys.Shift | Keys.Left: case (Keys.Shift | Keys.Right):
case Keys.Shift | Keys.Up: case (Keys.Shift | Keys.Left):
case Keys.Shift | Keys.Down: case (Keys.Shift | Keys.Up):
case (Keys.Shift | Keys.Down):
return true; return true;
default: break;
} }
return base.IsInputKey(keyData); return base.IsInputKey(keyData);
} }
@ -318,6 +343,7 @@ namespace DS4Windows
case Keys.Right: case Keys.Right:
case Keys.Up: case Keys.Up:
case Keys.Down: case Keys.Down:
{
if (e.Shift) if (e.Shift)
{ {
@ -326,6 +352,8 @@ namespace DS4Windows
{ {
} }
break; break;
}
default: break;
} }
} }
@ -340,6 +368,7 @@ namespace DS4Windows
int som = bgc + 11 * (int)(value * 0.0039215); int som = bgc + 11 * (int)(value * 0.0039215);
tb.BackColor = Color.FromArgb(tb.Name.ToLower().Contains("red") ? som : sat, tb.Name.ToLower().Contains("green") ? som : sat, tb.Name.ToLower().Contains("blue") ? som : sat); tb.BackColor = Color.FromArgb(tb.Name.ToLower().Contains("red") ? som : sat, tb.Name.ToLower().Contains("green") ? som : sat, tb.Name.ToLower().Contains("blue") ? som : sat);
} }
alphacolor = Math.Max(tBRedBar.Value, Math.Max(tBGreenBar.Value, tBBlueBar.Value)); alphacolor = Math.Max(tBRedBar.Value, Math.Max(tBGreenBar.Value, tBBlueBar.Value));
reg = Color.FromArgb(tBRedBar.Value, tBGreenBar.Value, tBBlueBar.Value); reg = Color.FromArgb(tBRedBar.Value, tBGreenBar.Value, tBBlueBar.Value);
full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg); full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg);
@ -378,6 +407,7 @@ namespace DS4Windows
tBBlueBar.Value = advColorDialog.Color.B; tBBlueBar.Value = advColorDialog.Color.B;
extraChanged = true; extraChanged = true;
} }
if (device < 4) if (device < 4)
DS4LightBar.forcelight[device] = false; DS4LightBar.forcelight[device] = false;
} }
@ -416,8 +446,10 @@ namespace DS4Windows
if (s[i] >= 'A' && s[i] <= 'Z') if (s[i] >= 'A' && s[i] <= 'Z')
s = s.Insert(i, " "); s = s.Insert(i, " ");
} }
if (s == "Guide") if (s == "Guide")
s = guideText; s = guideText;
return s; return s;
} }
@ -431,6 +463,7 @@ namespace DS4Windows
{ {
if (!loading && extraChanged) if (!loading && extraChanged)
Global.UpdateDS4Extra(device, button.Name, !rBShiftModifer.Checked, GetExtras()); Global.UpdateDS4Extra(device, button.Name, !rBShiftModifer.Checked, GetExtras());
object tagO = Global.GetDS4Action(device, button.Name, rBShiftModifer.Checked); object tagO = Global.GetDS4Action(device, button.Name, rBShiftModifer.Checked);
if (rBShiftModifer.Checked) if (rBShiftModifer.Checked)
btnDefault.Text = Properties.Resources.FallBack; btnDefault.Text = Properties.Resources.FallBack;
@ -443,8 +476,11 @@ namespace DS4Windows
newaction = false; newaction = false;
Highlight_Leave(null, null); Highlight_Leave(null, null);
foreach (Control control in Controls) foreach (Control control in Controls)
{
if (control is Button) if (control is Button)
((Button)control).BackColor = SystemColors.Control; ((Button)control).BackColor = SystemColors.Control;
}
if (tagO != null) if (tagO != null)
{ {
if (tagO is int || tagO is ushort) if (tagO is int || tagO is ushort)
@ -452,19 +488,24 @@ namespace DS4Windows
int tag = int.Parse(tagO.ToString()); int tag = int.Parse(tagO.ToString());
int i; int i;
foreach (Control control in Controls) foreach (Control control in Controls)
{
if (control is Button) if (control is Button)
{
if (int.TryParse(control.Tag?.ToString(), out i) && i == tag) if (int.TryParse(control.Tag?.ToString(), out i) && i == tag)
{ {
((Button)control).BackColor = Color.LightGreen; ((Button)control).BackColor = Color.LightGreen;
break; break;
} }
}
}
} }
else if (tagO is int[]) else if (tagO is int[])
{ {
int[] tag = (int[])tagO; int[] tag = (int[])tagO;
lBMacroOn.Visible = true; lBMacroOn.Visible = true;
foreach (int i in tag) foreach (int i in tag)
macrostag.Add(i); macrostag.Add(i);
if (Global.GetDS4KeyType(device, button.Name, rBShiftModifer.Checked).HasFlag(DS4KeyType.HoldMacro)) if (Global.GetDS4KeyType(device, button.Name, rBShiftModifer.Checked).HasFlag(DS4KeyType.HoldMacro))
macrorepeat = true; macrorepeat = true;
} }
@ -472,25 +513,33 @@ namespace DS4Windows
{ {
string tag; string tag;
if (tagO is X360Controls) if (tagO is X360Controls)
{
tag = getX360ControlsByName((X360Controls)tagO); tag = getX360ControlsByName((X360Controls)tagO);
}
else else
tag = tagO.ToString(); tag = tagO.ToString();
foreach (Control control in Controls) foreach (Control control in Controls)
{
if (control is Button) if (control is Button)
{
if (control.Tag?.ToString() == tag) if (control.Tag?.ToString() == tag)
{ {
((Button)control).BackColor = Color.LightGreen; ((Button)control).BackColor = Color.LightGreen;
break; break;
} }
}
}
foreach (Control control in pnl360Controls.Controls) foreach (Control control in pnl360Controls.Controls)
{
if (control is Button) if (control is Button)
{
if (control.Tag?.ToString().Substring(4) == tag) if (control.Tag?.ToString().Substring(4) == tag)
{ {
Hightlight_Hover(((Button)control), null); Hightlight_Hover(((Button)control), null);
break; break;
} }
}
}
} }
} }
else else
@ -504,22 +553,33 @@ namespace DS4Windows
tag = getX360ControlsByName((X360Controls)tagO); tag = getX360ControlsByName((X360Controls)tagO);
else else
tag = tagO.ToString(); tag = tagO.ToString();
foreach (Control control in Controls) foreach (Control control in Controls)
{
if (control is Button) if (control is Button)
{
if (control.Tag != null && control.Tag.ToString().Contains("X360") ? control.Tag?.ToString().Substring(4) == tag : control.Tag?.ToString() == tag) if (control.Tag != null && control.Tag.ToString().Contains("X360") ? control.Tag?.ToString().Substring(4) == tag : control.Tag?.ToString() == tag)
{ {
((Button)control).BackColor = Color.LightGreen; ((Button)control).BackColor = Color.LightGreen;
break; break;
} }
}
}
foreach (Control control in pnl360Controls.Controls) foreach (Control control in pnl360Controls.Controls)
{
if (control is Button) if (control is Button)
{
if (control.Tag?.ToString().Substring(4) == tag) if (control.Tag?.ToString().Substring(4) == tag)
{ {
Hightlight_Hover(((Button)control), null); Hightlight_Hover(((Button)control), null);
break; break;
} }
}
}
} }
} }
string dcExtras = Global.GetDS4Extra(device, button.Name, rBShiftModifer.Checked); string dcExtras = Global.GetDS4Extra(device, button.Name, rBShiftModifer.Checked);
string[] extras = null; string[] extras = null;
if (!string.IsNullOrEmpty(dcExtras)) if (!string.IsNullOrEmpty(dcExtras))
@ -535,6 +595,7 @@ namespace DS4Windows
if (int.TryParse(extras[0], out b)) nUDHeavy.Value = b; if (int.TryParse(extras[0], out b)) nUDHeavy.Value = b;
if (int.TryParse(extras[1], out b)) nUDLight.Value = b; if (int.TryParse(extras[1], out b)) nUDLight.Value = b;
if (int.TryParse(extras[2], out b)) if (int.TryParse(extras[2], out b))
{
if (b == 1) if (b == 1)
{ {
cBLightbar.Checked = true; cBLightbar.Checked = true;
@ -552,7 +613,10 @@ namespace DS4Windows
nUDLightFlash.Value = 0; nUDLightFlash.Value = 0;
cBLightbar.Checked = false; cBLightbar.Checked = false;
} }
}
if (int.TryParse(extras[7], out b)) if (int.TryParse(extras[7], out b))
{
if (b == 1) if (b == 1)
{ {
cBMouse.Checked = true; cBMouse.Checked = true;
@ -563,7 +627,7 @@ namespace DS4Windows
nUDMouse.Value = 25; nUDMouse.Value = 25;
cBMouse.Checked = false; cBMouse.Checked = false;
} }
}
} }
catch catch
{ {
@ -627,34 +691,41 @@ namespace DS4Windows
case X360Controls.MouseLeft: return "Mouse Left"; case X360Controls.MouseLeft: return "Mouse Left";
case X360Controls.MouseRight: return "Mouse Right"; case X360Controls.MouseRight: return "Mouse Right";
case X360Controls.Unbound: return "Unbound"; case X360Controls.Unbound: return "Unbound";
default: break;
} }
return "Unbound"; return "Unbound";
} }
private void bnTest_Click(object sender, EventArgs e) private void bnTest_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender;
if (device < 4) if (device < 4)
if (((Button)sender).Text == Properties.Resources.TestText) {
if (btn.Text == Properties.Resources.TestText)
{ {
Program.rootHub.setRumble((byte)nUDHeavy.Value, (byte)nUDLight.Value, device); Program.rootHub.setRumble((byte)nUDHeavy.Value, (byte)nUDLight.Value, device);
((Button)sender).Text = Properties.Resources.StopText; btn.Text = Properties.Resources.StopText;
} }
else else
{ {
Program.rootHub.setRumble(0, 0, device); Program.rootHub.setRumble(0, 0, device);
((Button)sender).Text = Properties.Resources.TestText; btn.Text = Properties.Resources.TestText;
} }
}
else else
if (((Button)sender).Text == Properties.Resources.TestText) {
if (btn.Text == Properties.Resources.TestText)
{ {
Program.rootHub.setRumble((byte)nUDHeavy.Value, (byte)nUDLight.Value, 0); Program.rootHub.setRumble((byte)nUDHeavy.Value, (byte)nUDLight.Value, 0);
((Button)sender).Text = Properties.Resources.StopText; btn.Text = Properties.Resources.StopText;
} }
else else
{ {
Program.rootHub.setRumble(0, 0, 0); Program.rootHub.setRumble(0, 0, 0);
((Button)sender).Text = Properties.Resources.TestText; btn.Text = Properties.Resources.TestText;
} }
}
} }
private void ExtraChanged(object sender, EventArgs e) private void ExtraChanged(object sender, EventArgs e)
@ -671,6 +742,7 @@ namespace DS4Windows
else else
Program.rootHub.setRumble((byte)nUDHeavy.Value, (byte)nUDLight.Value, 0); Program.rootHub.setRumble((byte)nUDHeavy.Value, (byte)nUDLight.Value, 0);
} }
extraChanged = true; extraChanged = true;
} }

View File

@ -266,6 +266,15 @@
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.nUDLSAntiDead = new System.Windows.Forms.NumericUpDown(); this.nUDLSAntiDead = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.maxZoneTabPage = new System.Windows.Forms.TabPage();
this.nUDR2Maxzone = new System.Windows.Forms.NumericUpDown();
this.nUDL2Maxzone = new System.Windows.Forms.NumericUpDown();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.nUDRSMaxZone = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
this.nUDLSMaxZone = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.fLPSettings = new System.Windows.Forms.FlowLayoutPanel(); this.fLPSettings = new System.Windows.Forms.FlowLayoutPanel();
this.gBGyro = new System.Windows.Forms.GroupBox(); this.gBGyro = new System.Windows.Forms.GroupBox();
this.rBSAControls = new System.Windows.Forms.RadioButton(); this.rBSAControls = new System.Windows.Forms.RadioButton();
@ -312,15 +321,6 @@
this.shareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.shareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.maxZoneTabPage = new System.Windows.Forms.TabPage();
this.label5 = new System.Windows.Forms.Label();
this.nUDLSMaxZone = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
this.nUDRSMaxZone = new System.Windows.Forms.NumericUpDown();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.nUDL2Maxzone = new System.Windows.Forms.NumericUpDown();
this.nUDR2Maxzone = new System.Windows.Forms.NumericUpDown();
this.advColorDialog = new DS4Windows.AdvancedColorDialog(); this.advColorDialog = new DS4Windows.AdvancedColorDialog();
((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit();
@ -386,6 +386,11 @@
((System.ComponentModel.ISupportInitialize)(this.nUDL2AntiDead)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDL2AntiDead)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSAntiDead)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDRSAntiDead)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSAntiDead)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDLSAntiDead)).BeginInit();
this.maxZoneTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDR2Maxzone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDL2Maxzone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSMaxZone)).BeginInit();
this.fLPSettings.SuspendLayout(); this.fLPSettings.SuspendLayout();
this.gBGyro.SuspendLayout(); this.gBGyro.SuspendLayout();
this.pnlSAMouse.SuspendLayout(); this.pnlSAMouse.SuspendLayout();
@ -398,11 +403,6 @@
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit();
this.cMGyroTriggers.SuspendLayout(); this.cMGyroTriggers.SuspendLayout();
this.maxZoneTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDLSMaxZone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDL2Maxzone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDR2Maxzone)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// lowColorChooserButton // lowColorChooserButton
@ -2759,6 +2759,128 @@
resources.ApplyResources(this.label1, "label1"); resources.ApplyResources(this.label1, "label1");
this.label1.Name = "label1"; this.label1.Name = "label1";
// //
// maxZoneTabPage
//
this.maxZoneTabPage.Controls.Add(this.nUDR2Maxzone);
this.maxZoneTabPage.Controls.Add(this.nUDL2Maxzone);
this.maxZoneTabPage.Controls.Add(this.label8);
this.maxZoneTabPage.Controls.Add(this.label7);
this.maxZoneTabPage.Controls.Add(this.nUDRSMaxZone);
this.maxZoneTabPage.Controls.Add(this.label6);
this.maxZoneTabPage.Controls.Add(this.nUDLSMaxZone);
this.maxZoneTabPage.Controls.Add(this.label5);
resources.ApplyResources(this.maxZoneTabPage, "maxZoneTabPage");
this.maxZoneTabPage.Name = "maxZoneTabPage";
this.maxZoneTabPage.UseVisualStyleBackColor = true;
//
// nUDR2Maxzone
//
this.nUDR2Maxzone.DecimalPlaces = 2;
this.nUDR2Maxzone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDR2Maxzone, "nUDR2Maxzone");
this.nUDR2Maxzone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDR2Maxzone.Name = "nUDR2Maxzone";
this.nUDR2Maxzone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDR2Maxzone.ValueChanged += new System.EventHandler(this.nUDR2Maxzone_ValueChanged);
//
// nUDL2Maxzone
//
this.nUDL2Maxzone.DecimalPlaces = 2;
this.nUDL2Maxzone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDL2Maxzone, "nUDL2Maxzone");
this.nUDL2Maxzone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDL2Maxzone.Name = "nUDL2Maxzone";
this.nUDL2Maxzone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDL2Maxzone.ValueChanged += new System.EventHandler(this.nUDL2Maxzone_ValueChanged);
//
// label8
//
resources.ApplyResources(this.label8, "label8");
this.label8.Name = "label8";
//
// label7
//
resources.ApplyResources(this.label7, "label7");
this.label7.Name = "label7";
//
// nUDRSMaxZone
//
this.nUDRSMaxZone.DecimalPlaces = 2;
this.nUDRSMaxZone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDRSMaxZone, "nUDRSMaxZone");
this.nUDRSMaxZone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDRSMaxZone.Name = "nUDRSMaxZone";
this.nUDRSMaxZone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDRSMaxZone.ValueChanged += new System.EventHandler(this.nUDRSMaxZone_ValueChanged);
//
// label6
//
resources.ApplyResources(this.label6, "label6");
this.label6.Name = "label6";
//
// nUDLSMaxZone
//
this.nUDLSMaxZone.DecimalPlaces = 2;
this.nUDLSMaxZone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDLSMaxZone, "nUDLSMaxZone");
this.nUDLSMaxZone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDLSMaxZone.Name = "nUDLSMaxZone";
this.nUDLSMaxZone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDLSMaxZone.ValueChanged += new System.EventHandler(this.nUDLSMaxZone_ValueChanged);
//
// label5
//
resources.ApplyResources(this.label5, "label5");
this.label5.Name = "label5";
//
// fLPSettings // fLPSettings
// //
resources.ApplyResources(this.fLPSettings, "fLPSettings"); resources.ApplyResources(this.fLPSettings, "fLPSettings");
@ -3262,128 +3384,6 @@
resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem"); resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem");
this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged); this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged);
// //
// maxZoneTabPage
//
this.maxZoneTabPage.Controls.Add(this.nUDR2Maxzone);
this.maxZoneTabPage.Controls.Add(this.nUDL2Maxzone);
this.maxZoneTabPage.Controls.Add(this.label8);
this.maxZoneTabPage.Controls.Add(this.label7);
this.maxZoneTabPage.Controls.Add(this.nUDRSMaxZone);
this.maxZoneTabPage.Controls.Add(this.label6);
this.maxZoneTabPage.Controls.Add(this.nUDLSMaxZone);
this.maxZoneTabPage.Controls.Add(this.label5);
resources.ApplyResources(this.maxZoneTabPage, "maxZoneTabPage");
this.maxZoneTabPage.Name = "maxZoneTabPage";
this.maxZoneTabPage.UseVisualStyleBackColor = true;
//
// label5
//
resources.ApplyResources(this.label5, "label5");
this.label5.Name = "label5";
//
// nUDLSMaxZone
//
this.nUDLSMaxZone.DecimalPlaces = 2;
this.nUDLSMaxZone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDLSMaxZone, "nUDLSMaxZone");
this.nUDLSMaxZone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDLSMaxZone.Name = "nUDLSMaxZone";
this.nUDLSMaxZone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDLSMaxZone.ValueChanged += new System.EventHandler(this.nUDLSMaxZone_ValueChanged);
//
// label6
//
resources.ApplyResources(this.label6, "label6");
this.label6.Name = "label6";
//
// nUDRSMaxZone
//
this.nUDRSMaxZone.DecimalPlaces = 2;
this.nUDRSMaxZone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDRSMaxZone, "nUDRSMaxZone");
this.nUDRSMaxZone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDRSMaxZone.Name = "nUDRSMaxZone";
this.nUDRSMaxZone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDRSMaxZone.ValueChanged += new System.EventHandler(this.nUDRSMaxZone_ValueChanged);
//
// label7
//
resources.ApplyResources(this.label7, "label7");
this.label7.Name = "label7";
//
// label8
//
resources.ApplyResources(this.label8, "label8");
this.label8.Name = "label8";
//
// nUDL2Maxzone
//
this.nUDL2Maxzone.DecimalPlaces = 2;
this.nUDL2Maxzone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDL2Maxzone, "nUDL2Maxzone");
this.nUDL2Maxzone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDL2Maxzone.Name = "nUDL2Maxzone";
this.nUDL2Maxzone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDL2Maxzone.ValueChanged += new System.EventHandler(this.nUDL2Maxzone_ValueChanged);
//
// nUDR2Maxzone
//
this.nUDR2Maxzone.DecimalPlaces = 2;
this.nUDR2Maxzone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDR2Maxzone, "nUDR2Maxzone");
this.nUDR2Maxzone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDR2Maxzone.Name = "nUDR2Maxzone";
this.nUDR2Maxzone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDR2Maxzone.ValueChanged += new System.EventHandler(this.nUDR2Maxzone_ValueChanged);
//
// Options // Options
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
@ -3395,7 +3395,6 @@
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "Options"; this.Name = "Options";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Options_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Options_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Options_Closed);
this.Resize += new System.EventHandler(this.Options_Resize); this.Resize += new System.EventHandler(this.Options_Resize);
((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).EndInit();
@ -3473,6 +3472,12 @@
((System.ComponentModel.ISupportInitialize)(this.nUDL2AntiDead)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDL2AntiDead)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSAntiDead)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDRSAntiDead)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSAntiDead)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDLSAntiDead)).EndInit();
this.maxZoneTabPage.ResumeLayout(false);
this.maxZoneTabPage.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDR2Maxzone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDL2Maxzone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSMaxZone)).EndInit();
this.fLPSettings.ResumeLayout(false); this.fLPSettings.ResumeLayout(false);
this.gBGyro.ResumeLayout(false); this.gBGyro.ResumeLayout(false);
this.gBGyro.PerformLayout(); this.gBGyro.PerformLayout();
@ -3488,12 +3493,6 @@
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit();
this.cMGyroTriggers.ResumeLayout(false); this.cMGyroTriggers.ResumeLayout(false);
this.maxZoneTabPage.ResumeLayout(false);
this.maxZoneTabPage.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDLSMaxZone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDL2Maxzone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDR2Maxzone)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }

View File

@ -1690,22 +1690,6 @@ namespace DS4Windows
e.Cancel = true; e.Cancel = true;
} }
private void Options_Closed(object sender, FormClosedEventArgs e)
{
/*for (int i = 0; i < 4; i++)
LoadProfile(i, false, Program.rootHub); //Refreshes all profiles in case other controllers are using the same profile
if (olddinputcheck != cBDinput.Checked)
{
root.btnStartStop_Clicked(false);
root.btnStartStop_Clicked(false);
}
if (btnRumbleHeavyTest.Text == Properties.Resources.StopText)
Program.rootHub.setRumble(0, 0, (int)nUDSixaxis.Value - 1);
inputtimer.Stop();
sixaxisTimer.Stop();*/
//e.c
}
private void cBSlide_CheckedChanged(object sender, EventArgs e) private void cBSlide_CheckedChanged(object sender, EventArgs e)
{ {
bool slideChecked = cBSlide.Checked; bool slideChecked = cBSlide.Checked;

View File

@ -7778,7 +7778,7 @@ with profile</value>
<value>advColorDialog</value> <value>advColorDialog</value>
</data> </data>
<data name="&gt;&gt;advColorDialog.Type" xml:space="preserve"> <data name="&gt;&gt;advColorDialog.Type" xml:space="preserve">
<value>DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.67.0, Culture=neutral, PublicKeyToken=null</value> <value>DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.69.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;$this.Name" xml:space="preserve"> <data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>Options</value> <value>Options</value>

View File

@ -4,15 +4,9 @@ using System.ComponentModel;
using System.Threading; using System.Threading;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks;
using System.Linq; using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
using System.Drawing; using System.Drawing;
using DS4Windows.DS4Library; using DS4Windows.DS4Library;
@ -23,7 +17,7 @@ namespace DS4Windows
public byte red; public byte red;
public byte green; public byte green;
public byte blue; public byte blue;
public DS4Color(System.Drawing.Color c) public DS4Color(Color c)
{ {
red = c.R; red = c.R;
green = c.G; green = c.G;
@ -508,7 +502,8 @@ namespace DS4Windows
int thisError = Marshal.GetLastWin32Error(); int thisError = Marshal.GetLastWin32Error();
if (lastError != thisError) if (lastError != thisError)
{ {
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> encountered write failure: " + thisError); Console.WriteLine(Mac.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> encountered write failure: " + thisError);
Log.LogToGui(Mac.ToString() + " encountered write failure: " + thisError, true);
lastError = thisError; lastError = thisError;
} }
} }
@ -579,7 +574,18 @@ namespace DS4Windows
} }
else else
{ {
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> disconnect due to read failure: " + Marshal.GetLastWin32Error());
if (res == HidDevice.ReadStatus.WaitTimedOut)
{
Log.LogToGui(Mac.ToString() + " disconnected due to timeout", true);
}
else
{
int winError = Marshal.GetLastWin32Error();
Console.WriteLine(Mac.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> disconnect due to read failure: " + winError);
Log.LogToGui(Mac.ToString() + " disconnected due to read failure: " + winError, true);
}
sendOutputReport(true); // Kick Windows into noticing the disconnection. sendOutputReport(true); // Kick Windows into noticing the disconnection.
StopOutputUpdate(); StopOutputUpdate();
isDisconnecting = true; isDisconnecting = true;
@ -588,10 +594,6 @@ namespace DS4Windows
Removal?.Invoke(this, EventArgs.Empty); Removal?.Invoke(this, EventArgs.Empty);
}), null); }), null);
/*
if (Removal != null)
Removal(this, EventArgs.Empty);
*/
return; return;
} }
@ -603,7 +605,17 @@ namespace DS4Windows
HidDevice.ReadStatus res = hDevice.ReadAsyncWithFileStream(inputReport, READ_STREAM_TIMEOUT); HidDevice.ReadStatus res = hDevice.ReadAsyncWithFileStream(inputReport, READ_STREAM_TIMEOUT);
if (res != HidDevice.ReadStatus.Success) if (res != HidDevice.ReadStatus.Success)
{ {
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> disconnect due to read failure: " + Marshal.GetLastWin32Error()); if (res == HidDevice.ReadStatus.WaitTimedOut)
{
Log.LogToGui(Mac.ToString() + " disconnected due to timeout", true);
}
else
{
int winError = Marshal.GetLastWin32Error();
Console.WriteLine(Mac.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> disconnect due to read failure: " + winError);
Log.LogToGui(Mac.ToString() + " disconnected due to read failure: " + winError, true);
}
StopOutputUpdate(); StopOutputUpdate();
isDisconnecting = true; isDisconnecting = true;
uiContext.Send(new SendOrPostCallback(delegate (object state4) uiContext.Send(new SendOrPostCallback(delegate (object state4)
@ -611,8 +623,6 @@ namespace DS4Windows
Removal?.Invoke(this, EventArgs.Empty); Removal?.Invoke(this, EventArgs.Empty);
}), null); }), null);
//if (Removal != null)
// Removal(this, EventArgs.Empty);
return; return;
} }
else else
@ -756,6 +766,8 @@ namespace DS4Windows
if (shouldDisconnect) if (shouldDisconnect)
{ {
Log.LogToGui(Mac.ToString() + " disconnecting due to idle disconnect", false);
if (conType == ConnectionType.BT) if (conType == ConnectionType.BT)
{ {
if (DisconnectBT(true)) if (DisconnectBT(true))
@ -843,7 +855,9 @@ namespace DS4Windows
{ {
if (!writeOutput()) if (!writeOutput())
{ {
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> encountered synchronous write failure: " + Marshal.GetLastWin32Error()); int winError = Marshal.GetLastWin32Error();
Console.WriteLine(Mac.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> encountered synchronous write failure: " + winError);
Log.LogToGui(Mac.ToString() + " encountered synchronous write failure: " + winError, true);
quitOutputThread = true; quitOutputThread = true;
} }
} }
@ -927,8 +941,6 @@ namespace DS4Windows
{ {
Removal?.Invoke(this, EventArgs.Empty); Removal?.Invoke(this, EventArgs.Empty);
}), null); }), null);
//Removal?.Invoke(this, EventArgs.Empty);
} }
} }
@ -960,11 +972,6 @@ namespace DS4Windows
{ {
Removal?.Invoke(this, EventArgs.Empty); Removal?.Invoke(this, EventArgs.Empty);
}), null); }), null);
/*
if (Removal != null)
Removal(this, EventArgs.Empty);
*/
} }
else if (result && !remove) else if (result && !remove)
{ {

View File

@ -99,7 +99,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DS4Control\ControlSerivce.cs" /> <Compile Include="DS4Control\ControlService.cs" />
<Compile Include="DS4Control\DS4LightBar.cs" /> <Compile Include="DS4Control\DS4LightBar.cs" />
<Compile Include="DS4Control\DS4StateFieldMapping.cs" /> <Compile Include="DS4Control\DS4StateFieldMapping.cs" />
<Compile Include="DS4Control\InputMethods.cs" /> <Compile Include="DS4Control\InputMethods.cs" />

View File

@ -304,14 +304,21 @@ namespace DS4Windows
if (!safeReadHandle.IsInvalid && fileStream.CanRead) if (!safeReadHandle.IsInvalid && fileStream.CanRead)
{ {
Task<int> readTask = fileStream.ReadAsync(inputBuffer, 0, inputBuffer.Length); Task<int> readTask = fileStream.ReadAsync(inputBuffer, 0, inputBuffer.Length);
readTask.Wait(timeout); bool success = readTask.Wait(timeout);
if (readTask.Result > 0) if (success)
{ {
return ReadStatus.Success; if (readTask.Result > 0)
{
return ReadStatus.Success;
}
else
{
return ReadStatus.NoDataRead;
}
} }
else else
{ {
return ReadStatus.NoDataRead; return ReadStatus.WaitTimedOut;
} }
} }