diff --git a/.gitignore b/.gitignore index 2f72fc4..535449e 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,6 @@ $RECYCLE.BIN/ # Mac desktop service store files .DS_Store + +.vs/DS4Windows/*/sqlite3/storage.ide + diff --git a/DS4Windows.sln b/DS4Windows.sln index 454a045..24fbce3 100644 --- a/DS4Windows.sln +++ b/DS4Windows.sln @@ -9,18 +9,24 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Debug|Any CPU.Build.0 = Debug|Any CPU {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Debug|x64.ActiveCfg = Debug|x64 {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Debug|x64.Build.0 = Debug|x64 + {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Debug|x86.ActiveCfg = Debug|x86 + {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Debug|x86.Build.0 = Debug|x86 {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Release|Any CPU.ActiveCfg = Release|Any CPU {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Release|Any CPU.Build.0 = Release|Any CPU {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Release|x64.ActiveCfg = Release|x64 {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Release|x64.Build.0 = Release|x64 + {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Release|x86.ActiveCfg = Release|x86 + {7B9354BF-AF82-4CCB-A83D-4BEB1E9D8C96}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 859cecf..e4a9f4d 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -24,9 +24,9 @@ namespace DS4Windows public bool recordingMacro = false; public event EventHandler Debug = null; bool[] buttonsdown = new bool[4] { false, false, false, false }; - List dcs = new List(); bool[] held = new bool[DS4_CONTROLLER_COUNT]; int[] oldmouse = new int[DS4_CONTROLLER_COUNT] { -1, -1, -1, -1 }; + Thread tempThread; //SoundPlayer sp = new SoundPlayer(); private class X360Data @@ -41,18 +41,20 @@ namespace DS4Windows { //sp.Stream = Properties.Resources.EE; // Cause thread affinity to not be tied to main GUI thread - Thread x360Thread = new Thread(() => { x360Bus = new X360Device(); }); - x360Thread.IsBackground = true; - x360Thread.Priority = ThreadPriority.Normal; - x360Thread.Name = "SCP Virtual Bus Thread"; - x360Thread.Start(); - while (!x360Thread.ThreadState.HasFlag(ThreadState.Stopped)) + /*Task x360task = new Task(() => { Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; x360Bus = new X360Device(); }); + x360task.Start(); + while (!x360task.IsCompleted) + Thread.SpinWait(500); + */ + tempThread = new Thread(() => { x360Bus = new X360Device(); }); + tempThread.Priority = ThreadPriority.AboveNormal; + tempThread.IsBackground = true; + tempThread.Start(); + while (tempThread.IsAlive) { Thread.SpinWait(500); } - AddtoDS4List(); - for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++) { processingData[i] = new X360Data(); @@ -63,44 +65,10 @@ namespace DS4Windows } } - void AddtoDS4List() - { - dcs.Add(DS4Controls.Cross); - dcs.Add(DS4Controls.Circle); - dcs.Add(DS4Controls.Square); - dcs.Add(DS4Controls.Triangle); - dcs.Add(DS4Controls.Options); - dcs.Add(DS4Controls.Share); - dcs.Add(DS4Controls.DpadUp); - dcs.Add(DS4Controls.DpadDown); - dcs.Add(DS4Controls.DpadLeft); - dcs.Add(DS4Controls.DpadRight); - dcs.Add(DS4Controls.PS); - dcs.Add(DS4Controls.L1); - dcs.Add(DS4Controls.R1); - dcs.Add(DS4Controls.L2); - dcs.Add(DS4Controls.R2); - dcs.Add(DS4Controls.L3); - dcs.Add(DS4Controls.R3); - dcs.Add(DS4Controls.LXPos); - dcs.Add(DS4Controls.LXNeg); - dcs.Add(DS4Controls.LYPos); - dcs.Add(DS4Controls.LYNeg); - dcs.Add(DS4Controls.RXPos); - dcs.Add(DS4Controls.RXNeg); - dcs.Add(DS4Controls.RYPos); - dcs.Add(DS4Controls.RYNeg); - dcs.Add(DS4Controls.SwipeUp); - dcs.Add(DS4Controls.SwipeDown); - dcs.Add(DS4Controls.SwipeLeft); - dcs.Add(DS4Controls.SwipeRight); - } - - private async void WarnExclusiveModeFailure(DS4Device device) + private void WarnExclusiveModeFailure(DS4Device device) { if (DS4Devices.isExclusiveMode && !device.isExclusive()) { - await Task.Delay(5); string message = Properties.Resources.CouldNotOpenDS4.Replace("*Mac address*", device.getMacAddress()) + " " + Properties.Resources.QuitOtherPrograms; LogDebug(message, true); @@ -108,7 +76,7 @@ namespace DS4Windows } } - public bool Start(bool showlog = true) + public bool Start(object tempui, bool showlog = true) { if (x360Bus.Open() && x360Bus.Start()) { @@ -138,14 +106,25 @@ namespace DS4Windows if (showlog) LogDebug(Properties.Resources.FoundController + device.getMacAddress() + " (" + device.getConnectionType() + ")"); - WarnExclusiveModeFailure(device); + Task task = new Task(() => { Thread.Sleep(5); WarnExclusiveModeFailure(device); }); + task.Start(); + DS4Controllers[i] = device; - device.setUiContext(SynchronizationContext.Current); + device.setUiContext(tempui as SynchronizationContext); device.Removal += this.On_DS4Removal; device.Removal += DS4Devices.On_Removal; device.SyncChange += this.On_SyncChange; device.SyncChange += DS4Devices.UpdateSerial; device.SerialChange += this.On_SerialChange; + if (device.isValidSerial() && containsLinkedProfile(device.getMacAddress())) + { + ProfilePath[i] = getLinkedProfile(device.getMacAddress()); + } + else + { + ProfilePath[i] = OlderProfilePath[i]; + } + LoadProfile(i, false, this, false, false); touchPad[i] = new Mouse(i, device); device.LightBarColor = getMainColor(i); @@ -208,7 +187,6 @@ namespace DS4Windows } runHotPlug = true; - return true; } @@ -222,6 +200,8 @@ namespace DS4Windows if (showlog) LogDebug(Properties.Resources.StoppingX360); + LogDebug("Closing connection to Scp Virtual Bus"); + bool anyUnplugged = false; for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++) { @@ -246,8 +226,7 @@ namespace DS4Windows DS4LightBar.forcelight[i] = false; DS4LightBar.forcedFlash[i] = 0; DS4LightBar.defaultLight = true; - DS4LightBar.updateLightBar(DS4Controllers[i], i, CurrentState[i], - ExposedState[i], touchPad[i]); + DS4LightBar.updateLightBar(DS4Controllers[i], i); tempDevice.IsRemoved = true; Thread.Sleep(50); } @@ -315,7 +294,8 @@ namespace DS4Windows if (DS4Controllers[Index] == null) { LogDebug(Properties.Resources.FoundController + device.getMacAddress() + " (" + device.getConnectionType() + ")"); - WarnExclusiveModeFailure(device); + Task task = new Task(() => { Thread.Sleep(5); WarnExclusiveModeFailure(device); }); + task.Start(); DS4Controllers[Index] = device; device.setUiContext(uiContext); device.Removal += this.On_DS4Removal; @@ -323,6 +303,16 @@ namespace DS4Windows device.SyncChange += this.On_SyncChange; device.SyncChange += DS4Devices.UpdateSerial; device.SerialChange += this.On_SerialChange; + if (device.isValidSerial() && containsLinkedProfile(device.getMacAddress())) + { + ProfilePath[i] = getLinkedProfile(device.getMacAddress()); + } + else + { + ProfilePath[i] = OlderProfilePath[i]; + } + + LoadProfile(i, false, this, false, false); touchPad[Index] = new Mouse(Index, device); device.LightBarColor = getMainColor(Index); device.Report += this.On_Report; @@ -695,6 +685,7 @@ namespace DS4Windows public bool[] inWarnMonitor = new bool[4] { false, false, false, false }; private byte[] currentBattery = new byte[4] { 0, 0, 0, 0 }; private bool[] charging = new bool[4] { false, false, false, false }; + private string[] tempStrings = new string[4] { string.Empty, string.Empty, string.Empty, string.Empty }; // Called every time a new input report has arrived protected virtual void On_Report(object sender, EventArgs e) @@ -714,9 +705,13 @@ namespace DS4Windows if (getFlushHIDQueue(ind)) device.FlushHID(); - if (!string.IsNullOrEmpty(device.error)) + string devError = tempStrings[ind] = device.error; + if (!string.IsNullOrEmpty(devError)) { - LogDebug(device.error); + device.getUiContext()?.Post(new SendOrPostCallback(delegate (object state) + { + LogDebug(devError); + }), null); } if (inWarnMonitor[ind]) @@ -749,12 +744,13 @@ namespace DS4Windows device.getCurrentState(CurrentState[ind]); DS4State cState = CurrentState[ind]; - device.getPreviousState(PreviousState[ind]); - DS4State pState = PreviousState[ind]; + DS4State pState = device.getPreviousStateRef(); + //device.getPreviousState(PreviousState[ind]); + //DS4State pState = PreviousState[ind]; - if (!device.firstReport && device.IsAlive()) + if (device.firstReport && device.IsAlive()) { - device.firstReport = true; + device.firstReport = false; device.getUiContext()?.Post(new SendOrPostCallback(delegate (object state) { OnDeviceStatusChanged(this, ind); @@ -771,9 +767,7 @@ namespace DS4Windows } if (getEnableTouchToggle(ind)) - { CheckForTouchToggle(ind, cState, pState); - } cState = Mapping.SetCurveAndDeadzone(ind, cState); @@ -806,7 +800,7 @@ namespace DS4Windows Mapping.Commit(ind); // Update the GUI/whatever. - DS4LightBar.updateLightBar(device, ind, cState, ExposedState[ind], touchPad[ind]); + DS4LightBar.updateLightBar(device, ind); } } @@ -833,131 +827,73 @@ namespace DS4Windows } } - public string GetInputkeys(int ind) + public DS4Controls GetActiveInputControl(int ind) { DS4State cState = CurrentState[ind]; DS4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; - string result = "nothing"; + DS4Controls result = DS4Controls.None; if (DS4Controllers[ind] != null) { if (Mapping.getBoolButtonMapping(cState.Cross)) - { - result = "Cross"; - } + result = DS4Controls.Cross; else if (Mapping.getBoolButtonMapping(cState.Circle)) - { - result = "Circle"; - } + result = DS4Controls.Circle; else if (Mapping.getBoolButtonMapping(cState.Triangle)) - { - result = "Triangle"; - } + result = DS4Controls.Triangle; else if (Mapping.getBoolButtonMapping(cState.Square)) - { - result = "Square"; - } + result = DS4Controls.Square; else if (Mapping.getBoolButtonMapping(cState.L1)) - { - result = "L1"; - } + result = DS4Controls.L1; else if (Mapping.getBoolTriggerMapping(cState.L2)) - { - result = "L2"; - } + result = DS4Controls.L2; else if (Mapping.getBoolButtonMapping(cState.L3)) - { - result = "L3"; - } + result = DS4Controls.L3; else if (Mapping.getBoolButtonMapping(cState.R1)) - { - result = "R1"; - } + result = DS4Controls.R1; else if (Mapping.getBoolTriggerMapping(cState.R2)) - { - result = "R2"; - } + result = DS4Controls.R2; else if (Mapping.getBoolButtonMapping(cState.R3)) - { - result = "R3"; - } + result = DS4Controls.R3; else if (Mapping.getBoolButtonMapping(cState.DpadUp)) - { - result = "Up"; - } + result = DS4Controls.DpadUp; else if (Mapping.getBoolButtonMapping(cState.DpadDown)) - { - result = "Down"; - } + result = DS4Controls.DpadDown; else if (Mapping.getBoolButtonMapping(cState.DpadLeft)) - { - result = "Left"; - } + result = DS4Controls.DpadLeft; else if (Mapping.getBoolButtonMapping(cState.DpadRight)) - { - result = "Right"; - } + result = DS4Controls.DpadRight; else if (Mapping.getBoolButtonMapping(cState.Share)) - { - result = "Share"; - } + result = DS4Controls.Share; else if (Mapping.getBoolButtonMapping(cState.Options)) - { - result = "Options"; - } + result = DS4Controls.Options; else if (Mapping.getBoolButtonMapping(cState.PS)) - { - result = "PS"; - } + result = DS4Controls.PS; else if (Mapping.getBoolAxisDirMapping(cState.LX, true)) - { - result = "LS Right"; - } + result = DS4Controls.LXPos; else if (Mapping.getBoolAxisDirMapping(cState.LX, false)) - { - result = "LS Left"; - } + result = DS4Controls.LXNeg; else if (Mapping.getBoolAxisDirMapping(cState.LY, true)) - { - result = "LS Down"; - } + result = DS4Controls.LYPos; else if (Mapping.getBoolAxisDirMapping(cState.LY, false)) - { - result = "LS Up"; - } + result = DS4Controls.LYNeg; else if (Mapping.getBoolAxisDirMapping(cState.RX, true)) - { - result = "RS Right"; - } + result = DS4Controls.RXPos; else if (Mapping.getBoolAxisDirMapping(cState.RX, false)) - { - result = "RS Left"; - } + result = DS4Controls.RXNeg; else if (Mapping.getBoolAxisDirMapping(cState.RY, true)) - { - result = "RS Down"; - } + result = DS4Controls.RYPos; else if (Mapping.getBoolAxisDirMapping(cState.RY, false)) - { - result = "RS Up"; - } + result = DS4Controls.RYNeg; else if (Mapping.getBoolTouchMapping(tp.leftDown)) - { - result = "Touch Left"; - } + result = DS4Controls.TouchLeft; else if (Mapping.getBoolTouchMapping(tp.rightDown)) - { - result = "Touch Right"; - } + result = DS4Controls.TouchRight; else if (Mapping.getBoolTouchMapping(tp.multiDown)) - { - result = "Touch Multi"; - } + result = DS4Controls.TouchMulti; else if (Mapping.getBoolTouchMapping(tp.upperDown)) - { - result = "Touch Upper"; - } + result = DS4Controls.TouchUpper; } return result; @@ -979,20 +915,16 @@ namespace DS4Windows oldscrollvalue[deviceID] = getScrollSensitivity(deviceID); getTouchSensitivity()[deviceID] = 0; getScrollSensitivity()[deviceID] = 0; - LogDebug(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : - Properties.Resources.TouchpadMovementOff); - Log.LogToTray(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : - Properties.Resources.TouchpadMovementOff); + LogDebug(Properties.Resources.TouchpadMovementOff); + Log.LogToTray(Properties.Resources.TouchpadMovementOff); touchreleased[deviceID] = false; } else if (touchreleased[deviceID]) { getTouchSensitivity()[deviceID] = oldtouchvalue[deviceID]; getScrollSensitivity()[deviceID] = oldscrollvalue[deviceID]; - LogDebug(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : - Properties.Resources.TouchpadMovementOff); - Log.LogToTray(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : - Properties.Resources.TouchpadMovementOff); + LogDebug(Properties.Resources.TouchpadMovementOn); + Log.LogToTray(Properties.Resources.TouchpadMovementOn); touchreleased[deviceID] = false; } } diff --git a/DS4Windows/DS4Control/DS4LightBar.cs b/DS4Windows/DS4Control/DS4LightBar.cs index 1e33ec9..c4d36c2 100644 --- a/DS4Windows/DS4Control/DS4LightBar.cs +++ b/DS4Windows/DS4Control/DS4LightBar.cs @@ -34,10 +34,11 @@ namespace DS4Windows public static DS4Color[] forcedColor = new DS4Color[4]; public static byte[] forcedFlash = new byte[4]; internal const int PULSE_FLASH_DURATION = 2000; + internal const double PULSE_FLASH_SEGMENTS = PULSE_FLASH_DURATION / 40; internal const int PULSE_CHARGING_DURATION = 4000; + internal const double PULSE_CHARGING_SEGMENTS = PULSE_CHARGING_DURATION / 40; - public static void updateLightBar(DS4Device device, int deviceNum, DS4State cState, - DS4StateExposed eState, Mouse tp) + public static void updateLightBar(DS4Device device, int deviceNum) { DS4Color color; if (!defaultLight && !forcelight[deviceNum]) @@ -82,13 +83,9 @@ namespace DS4Windows } else if (getLedAsBatteryIndicator(deviceNum)) { - //if (device.Charging == false || device.Battery >= 100) // when charged, don't show the charging animation - { - DS4Color fullColor = getMainColor(deviceNum); - DS4Color lowColor = getLowColor(deviceNum); - - color = getTransitionedColor(lowColor, fullColor, device.getBattery()); - } + DS4Color fullColor = getMainColor(deviceNum); + DS4Color lowColor = getLowColor(deviceNum); + color = getTransitionedColor(lowColor, fullColor, device.getBattery()); } else { @@ -123,7 +120,8 @@ namespace DS4Windows { if (elapsed < PULSE_FLASH_DURATION) { - ratio = 100.0 * (elapsed / (double)PULSE_FLASH_DURATION); + elapsed = elapsed / 40; + ratio = 100.0 * (elapsed / PULSE_FLASH_SEGMENTS); } else { @@ -135,7 +133,8 @@ namespace DS4Windows { if (elapsed < PULSE_FLASH_DURATION) { - ratio = (0 - 100.0) * (elapsed / (double)PULSE_FLASH_DURATION) + 100.0; + elapsed = elapsed / 40; + ratio = (0 - 100.0) * (elapsed / PULSE_FLASH_SEGMENTS) + 100.0; } else { @@ -157,9 +156,12 @@ namespace DS4Windows TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - device.lastActive.Ticks); double botratio = timeratio.TotalMilliseconds; double topratio = TimeSpan.FromSeconds(idleDisconnectTimeout).TotalMilliseconds; - double ratio = 100.0 * (botratio / topratio); + double ratio = 100.0 * (botratio / topratio), elapsed = ratio; if (ratio >= 50.0 && ratio < 100.0) - color = getTransitionedColor(color, new DS4Color(0, 0, 0), (uint)((ratio - 50) * 2)); + { + color = getTransitionedColor(color, new DS4Color(0, 0, 0), + (uint)(-100.0 * (elapsed = 0.02 * (ratio - 50.0)) * (elapsed - 2.0))); + } else if (ratio >= 100.0) color = getTransitionedColor(color, new DS4Color(0, 0, 0), 100.0); } @@ -187,7 +189,8 @@ namespace DS4Windows { if (elapsed < PULSE_CHARGING_DURATION) { - ratio = 100.0 * (elapsed / (double)PULSE_CHARGING_DURATION); + elapsed = elapsed / 40; + ratio = 100.0 * (elapsed / PULSE_CHARGING_SEGMENTS); } else { @@ -199,7 +202,8 @@ namespace DS4Windows { if (elapsed < PULSE_CHARGING_DURATION) { - ratio = (0 - 100.0) * (elapsed / (double)PULSE_CHARGING_DURATION) + 100.0; + elapsed = elapsed / 40; + ratio = (0 - 100.0) * (elapsed / PULSE_CHARGING_SEGMENTS) + 100.0; } else { diff --git a/DS4Windows/DS4Control/DS4StateFieldMapping.cs b/DS4Windows/DS4Control/DS4StateFieldMapping.cs index e8d88c7..ab2030f 100644 --- a/DS4Windows/DS4Control/DS4StateFieldMapping.cs +++ b/DS4Windows/DS4Control/DS4StateFieldMapping.cs @@ -12,7 +12,7 @@ namespace DS4Windows public byte[] swipedirs = new byte[(int)DS4Controls.SwipeDown + 1]; public bool[] swipedirbools = new bool[(int)DS4Controls.SwipeDown + 1]; - public static ControlType[] mappedType = { ControlType.Unknown, // DS4Controls.None + public static ControlType[] mappedType = new ControlType[38] { ControlType.Unknown, // DS4Controls.None ControlType.AxisDir, // DS4Controls.LXNeg ControlType.AxisDir, // DS4Controls.LXPos ControlType.AxisDir, // DS4Controls.LYNeg @@ -90,11 +90,11 @@ namespace DS4Windows buttons[(int)DS4Controls.TouchUpper] = tp != null ? (!priorMouse ? tp.upperDown : tp.priorUpperDown) : false; buttons[(int)DS4Controls.TouchMulti] = tp != null ? (!priorMouse ? tp.multiDown : tp.priorMultiDown) : false; - int sixAxisX = -exposeState.getAccelX(); + int sixAxisX = -exposeState.getOutputAccelX(); gryodirs[(int)DS4Controls.GyroXPos] = sixAxisX > 0 ? sixAxisX : 0; gryodirs[(int)DS4Controls.GyroXNeg] = sixAxisX < 0 ? sixAxisX : 0; - int sixAxisZ = exposeState.getAccelZ(); + int sixAxisZ = exposeState.getOutputAccelZ(); gryodirs[(int)DS4Controls.GyroZPos] = sixAxisZ > 0 ? sixAxisZ : 0; gryodirs[(int)DS4Controls.GyroZNeg] = sixAxisZ < 0 ? sixAxisZ : 0; diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 8d858cb..ea31359 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -84,14 +84,14 @@ namespace DS4Windows public static DateTime[] oldnowKeyAct = new DateTime[4] { DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue }; - private static DS4Controls[] shiftTriggerMapping = { DS4Controls.None, DS4Controls.Cross, DS4Controls.Circle, DS4Controls.Square, + private static DS4Controls[] shiftTriggerMapping = new DS4Controls[26] { DS4Controls.None, DS4Controls.Cross, DS4Controls.Circle, DS4Controls.Square, DS4Controls.Triangle, DS4Controls.Options, DS4Controls.Share, DS4Controls.DpadUp, DS4Controls.DpadDown, DS4Controls.DpadLeft, DS4Controls.DpadRight, DS4Controls.PS, DS4Controls.L1, DS4Controls.R1, DS4Controls.L2, DS4Controls.R2, DS4Controls.L3, DS4Controls.R3, DS4Controls.TouchLeft, DS4Controls.TouchUpper, DS4Controls.TouchMulti, - DS4Controls.TouchRight, DS4Controls.GyroZNeg, DS4Controls.GyroZPos, DS4Controls.GyroXPos, DS4Controls.GyroXNeg + DS4Controls.TouchRight, DS4Controls.GyroZNeg, DS4Controls.GyroZPos, DS4Controls.GyroXPos, DS4Controls.GyroXNeg, }; - private static int[] ds4ControlMapping = { 0, // DS4Control.None + private static int[] ds4ControlMapping = new int[34] { 0, // DS4Control.None 16, // DS4Controls.LXNeg 20, // DS4Controls.LXPos 17, // DS4Controls.LYNeg @@ -145,8 +145,8 @@ namespace DS4Windows public static int mouseaccel = 0; public static int prevmouseaccel = 0; private static double horizontalRemainder = 0.0, verticalRemainder = 0.0; - private const int MOUSESPEEDFACTOR = 40; - private const double MOUSESTICKOFFSET = 0.03; + private const int MOUSESPEEDFACTOR = 30; + private const double MOUSESTICKOFFSET = 0.032; public static void Commit(int device) { @@ -219,18 +219,18 @@ namespace DS4Windows if (globalState.currentClicks.wUpCount != 0 && globalState.previousClicks.wUpCount == 0) { - InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, 100); + InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, 120); oldnow = DateTime.UtcNow; - wheel = 100; + wheel = 120; } else if (globalState.currentClicks.wUpCount == 0 && globalState.previousClicks.wUpCount != 0) wheel = 0; if (globalState.currentClicks.wDownCount != 0 && globalState.previousClicks.wDownCount == 0) { - InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, -100); + InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, -120); oldnow = DateTime.UtcNow; - wheel = -100; + wheel = -120; } if (globalState.currentClicks.wDownCount == 0 && globalState.previousClicks.wDownCount != 0) wheel = 0; @@ -914,17 +914,17 @@ namespace DS4Windows if (absx > SXD) { double ratioX = absx < maxValue ? (absx - SXD) / (double)(maxValue - SXD) : 1.0; - dState.Motion.accelX = Math.Sign(gyroX) * + dState.Motion.outputAccelX = Math.Sign(gyroX) * (int)Math.Min(128d, sxsens * 128d * ((1.0 - sxAntiDead) * ratioX + sxAntiDead)); } else { - dState.Motion.accelX = 0; + dState.Motion.outputAccelX = 0; } } else { - dState.Motion.accelX = Math.Sign(gyroX) * + dState.Motion.outputAccelX = Math.Sign(gyroX) * (int)Math.Min(128d, sxsens * 128d * (absx / 128d)); } @@ -934,51 +934,51 @@ namespace DS4Windows if (absz > SZD) { double ratioZ = absz < maxValue ? (absz - SZD) / (double)(maxValue - SZD) : 1.0; - dState.Motion.accelZ = Math.Sign(gyroZ) * + dState.Motion.outputAccelZ = Math.Sign(gyroZ) * (int)Math.Min(128d, szsens * 128d * ((1.0 - szAntiDead) * ratioZ + szAntiDead)); } else { - dState.Motion.accelZ = 0; + dState.Motion.outputAccelZ = 0; } } else { - dState.Motion.accelZ = Math.Sign(gyroZ) * + dState.Motion.outputAccelZ = Math.Sign(gyroZ) * (int)Math.Min(128d, szsens * 128d * (absz / 128d)); } int sxOutCurveMode = tempIntArray[device] = getSXOutCurveMode(device); if (sxOutCurveMode > 0) { - double temp = Math.Abs(dState.Motion.accelX) / 128.0; + double temp = Math.Abs(dState.Motion.outputAccelX) / 128.0; double sign = Math.Sign(temp); if (sxOutCurveMode == 1) { double output = temp * temp; - dState.Motion.accelX = (byte)(output * sign * 128.0); + dState.Motion.outputAccelX = (byte)(output * sign * 128.0); } else if (sxOutCurveMode == 2) { double output = temp * temp * temp; - dState.Motion.accelX = (byte)(output * 128.0); + dState.Motion.outputAccelX = (byte)(output * 128.0); } } int szOutCurveMode = tempIntArray[device] = getSZOutCurveMode(device); if (szOutCurveMode > 0) { - double temp = Math.Abs(dState.Motion.accelZ) / 128.0; + double temp = Math.Abs(dState.Motion.outputAccelZ) / 128.0; double sign = Math.Sign(temp); if (szOutCurveMode == 1) { double output = temp * temp; - dState.Motion.accelZ = (byte)(output * sign * 128.0); + dState.Motion.outputAccelZ = (byte)(output * sign * 128.0); } else if (szOutCurveMode == 2) { double output = temp * temp * temp; - dState.Motion.accelZ = (byte)(output * 128.0); + dState.Motion.outputAccelZ = (byte)(output * 128.0); } } } @@ -1010,11 +1010,15 @@ namespace DS4Windows { result = false; } - else + else if (trigger < 26) { DS4Controls ds = shiftTriggerMapping[trigger]; result = getBoolMapping2(device, ds, cState, eState, tp, fieldMapping); } + else if (trigger == 26) + { + result = cState.Touch1Finger; + } return result; } @@ -1127,6 +1131,64 @@ namespace DS4Windows keyType = dcs.keyType; } + if (usingExtra == DS4Controls.None || usingExtra == dcs.control) + { + bool shiftE = !string.IsNullOrEmpty(dcs.shiftExtras) && ShiftTrigger2(dcs.shiftTrigger, device, cState, eState, tp, fieldMapping); + bool regE = !string.IsNullOrEmpty(dcs.extras); + if ((regE || shiftE) && getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping)) + { + usingExtra = dcs.control; + string p; + if (shiftE) + p = dcs.shiftExtras; + else + p = dcs.extras; + + string[] extraS = p.Split(','); + int extrasSLen = extraS.Length; + int[] extras = new int[extrasSLen]; + for (int i = 0; i < extrasSLen; i++) + { + int b; + if (int.TryParse(extraS[i], out b)) + extras[i] = b; + } + + held[device] = true; + try + { + if (!(extras[0] == extras[1] && extras[1] == 0)) + ctrl.setRumble((byte)extras[0], (byte)extras[1], device); + + if (extras[2] == 1) + { + DS4Color color = new DS4Color { red = (byte)extras[3], green = (byte)extras[4], blue = (byte)extras[5] }; + DS4LightBar.forcedColor[device] = color; + DS4LightBar.forcedFlash[device] = (byte)extras[6]; + DS4LightBar.forcelight[device] = true; + } + + if (extras[7] == 1) + { + if (oldmouse[device] == -1) + oldmouse[device] = ButtonMouseSensitivity[device]; + ButtonMouseSensitivity[device] = extras[8]; + } + } + catch { } + } + else if ((regE || shiftE) && held[device]) + { + DS4LightBar.forcelight[device] = false; + DS4LightBar.forcedFlash[device] = 0; + ButtonMouseSensitivity[device] = oldmouse[device]; + oldmouse[device] = -1; + ctrl.setRumble(0, 0, device); + held[device] = false; + usingExtra = DS4Controls.None; + } + } + if (action != null) { if (actionType == DS4ControlSettings.ActionType.Macro) @@ -1351,64 +1413,6 @@ namespace DS4Windows resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping); } } - - if (usingExtra == DS4Controls.None || usingExtra == dcs.control) - { - bool shiftE = !string.IsNullOrEmpty(dcs.shiftExtras) && dcs.shiftExtras != "0,0,0,0,0,0,0,0" && ShiftTrigger2(dcs.shiftTrigger, device, cState, eState, tp, fieldMapping); - bool regE = !string.IsNullOrEmpty(dcs.extras) && dcs.extras != "0,0,0,0,0,0,0,0"; - if ((regE || shiftE) && getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping)) - { - usingExtra = dcs.control; - string p; - if (shiftE) - p = dcs.shiftExtras; - else - p = dcs.extras; - - string[] extraS = p.Split(','); - int extrasSLen = extraS.Length; - int[] extras = new int[extrasSLen]; - for (int i = 0; i < extrasSLen; i++) - { - int b; - if (int.TryParse(extraS[i], out b)) - extras[i] = b; - } - - held[device] = true; - try - { - if (!(extras[0] == extras[1] && extras[1] == 0)) - ctrl.setRumble((byte)extras[0], (byte)extras[1], device); - - if (extras[2] == 1) - { - DS4Color color = new DS4Color { red = (byte)extras[3], green = (byte)extras[4], blue = (byte)extras[5] }; - DS4LightBar.forcedColor[device] = color; - DS4LightBar.forcedFlash[device] = (byte)extras[6]; - DS4LightBar.forcelight[device] = true; - } - - if (extras[7] == 1) - { - if (oldmouse[device] == -1) - oldmouse[device] = ButtonMouseSensitivity[device]; - ButtonMouseSensitivity[device] = extras[8]; - } - } - catch { } - } - else if ((regE || shiftE) && held[device]) - { - DS4LightBar.forcelight[device] = false; - DS4LightBar.forcedFlash[device] = 0; - ButtonMouseSensitivity[device] = oldmouse[device]; - oldmouse[device] = -1; - ctrl.setRumble(0, 0, device); - held[device] = false; - usingExtra = DS4Controls.None; - } - } } outputfieldMapping.populateState(MappedState); @@ -1985,7 +1989,7 @@ namespace DS4Windows DS4Device d = ctrl.DS4Controllers[device]; //cus - DS4State tempPrevState = d.getPreviousState(); + DS4State tempPrevState = d.getPreviousStateRef(); // Only create one instance of previous DS4StateFieldMapping in case more than one multi-action // button is assigned if (previousFieldMapping == null) @@ -1999,7 +2003,7 @@ namespace DS4Windows { // pressed down action.pastTime = DateTime.UtcNow; - if (action.pastTime <= (action.firstTap + TimeSpan.FromMilliseconds(150))) + if (action.pastTime <= (action.firstTap + TimeSpan.FromMilliseconds(100))) { action.tappedOnce = tappedOnce = false; action.secondtouchbegin = secondtouchbegin = true; @@ -2024,7 +2028,7 @@ namespace DS4Windows { action.firstTouch = firstTouch = false; //firstTouch = false; - if (DateTime.UtcNow <= (action.pastTime + TimeSpan.FromMilliseconds(200)) && !tappedOnce) + if (DateTime.UtcNow <= (action.pastTime + TimeSpan.FromMilliseconds(150)) && !tappedOnce) { action.tappedOnce = tappedOnce = true; //tappedOnce = true; @@ -2064,7 +2068,7 @@ namespace DS4Windows } //if it fails the method resets, and tries again with a new tester value (gives tap a delay so tap and hold can work) } - else if (firstTouch && (DateTime.UtcNow - action.pastTime) > TimeSpan.FromMilliseconds(1000)) //helddown + else if (firstTouch && (DateTime.UtcNow - action.pastTime) > TimeSpan.FromMilliseconds(500)) //helddown { if (action.typeID == SpecialAction.ActionTypeId.MultiAction) { diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs index c92a875..87f7905 100644 --- a/DS4Windows/DS4Control/Mouse.cs +++ b/DS4Windows/DS4Control/Mouse.cs @@ -39,6 +39,8 @@ namespace DS4Windows { if (Global.isUsingSAforMouse(deviceNum) && Global.getGyroSensitivity(deviceNum) > 0) { + s = dev.getCurrentStateRef(); + triggeractivated = true; useReverseRatchet = Global.getGyroTriggerTurns(deviceNum); int i = 0; @@ -46,8 +48,8 @@ namespace DS4Windows if (!string.IsNullOrEmpty(ss[0])) { string s = string.Empty; - for (int index = 0, arlen = ss.Length; triggeractivated && index < arlen; index++) - //foreach (string s in ss) + for (int index = 0, arlen = ss.Length; + triggeractivated && index < arlen; index++) { s = ss[index]; if (!(int.TryParse(s, out i) && getDS4ControlsByName(i))) @@ -63,8 +65,6 @@ namespace DS4Windows cursor.sixaxisMoved(arg); else cursor.mouseRemainderReset(); - - dev.getCurrentState(s); } } @@ -98,11 +98,22 @@ namespace DS4Windows return false; } + private bool tempBool = false; public virtual void touchesMoved(object sender, TouchpadEventArgs arg) { - if (!Global.UseTPforControls[deviceNum]) + s = dev.getCurrentStateRef(); + + if (Global.getUseTPforControls(deviceNum) == false) { - cursor.touchesMoved(arg, dragging || dragging2); + int[] disArray = Global.getTouchDisInvertTriggers(deviceNum); + tempBool = true; + for (int i = 0, arlen = disArray.Length; tempBool && i < arlen; i++) + { + if (getDS4ControlsByName(disArray[i]) == false) + tempBool = false; + } + + cursor.touchesMoved(arg, dragging || dragging2, tempBool); wheel.touchesMoved(arg, dragging || dragging2); } else @@ -129,7 +140,6 @@ namespace DS4Windows slideleft = true; } - dev.getCurrentState(s); synthesizeMouseButtons(); } @@ -151,7 +161,7 @@ namespace DS4Windows secondtouchbegin = true; } - dev.getCurrentState(s); + s = dev.getCurrentStateRef(); synthesizeMouseButtons(); } @@ -186,7 +196,7 @@ namespace DS4Windows } } - dev.getCurrentState(s); + s = dev.getCurrentStateRef(); synthesizeMouseButtons(); } @@ -202,8 +212,7 @@ namespace DS4Windows public virtual void touchUnchanged(object sender, EventArgs unused) { - dev.getCurrentState(s); - //if (s.Touch1 || s.Touch2 || s.TouchButton) + s = dev.getCurrentStateRef(); synthesizeMouseButtons(); } @@ -254,7 +263,6 @@ namespace DS4Windows } s = remapped; - //remapped.CopyTo(s); } public virtual void touchButtonUp(object sender, TouchpadEventArgs arg) @@ -262,7 +270,7 @@ namespace DS4Windows pushed = DS4Controls.None; upperDown = leftDown = rightDown = multiDown = false; dev.setRumble(0, 0); - dev.getCurrentState(s); + s = dev.getCurrentStateRef(); if (s.Touch1 || s.Touch2) synthesizeMouseButtons(); } @@ -284,7 +292,7 @@ namespace DS4Windows rightDown = true; } - dev.getCurrentState(s); + s = dev.getCurrentStateRef(); synthesizeMouseButtons(); } diff --git a/DS4Windows/DS4Control/MouseCursor.cs b/DS4Windows/DS4Control/MouseCursor.cs index 60835e8..1738224 100644 --- a/DS4Windows/DS4Control/MouseCursor.cs +++ b/DS4Windows/DS4Control/MouseCursor.cs @@ -1,4 +1,5 @@ - +using System; + namespace DS4Windows { class MouseCursor @@ -19,10 +20,11 @@ namespace DS4Windows verticalDirection = Direction.Neutral; private Direction hDirection = Direction.Neutral, vDirection = Direction.Neutral; - private double GYRO_MOUSE_COEFFICIENT = 0.0095; - private int GYRO_MOUSE_DEADZONE = 12; - private double GYRO_MOUSE_OFFSET = 0.1463; - private double GYRO_SMOOTH_MOUSE_OFFSET = 0.14696; + private const double GYRO_MOUSE_COEFFICIENT = 0.0095; + private const int GYRO_MOUSE_DEADZONE = 10; + private const double GYRO_MOUSE_OFFSET = 0.1463; + private const double GYRO_SMOOTH_MOUSE_OFFSET = 0.14698; + private const double TOUCHPAD_MOUSE_OFFSET = 0.015; private const int SMOOTH_BUFFER_LEN = 3; private double[] xSmoothBuffer = new double[SMOOTH_BUFFER_LEN]; @@ -35,6 +37,7 @@ namespace DS4Windows int tempInt = 0; double tempDouble = 0.0; + bool tempBool = false; public virtual void sixaxisMoved(SixAxisEventArgs arg) { @@ -42,7 +45,8 @@ namespace DS4Windows deltaX = Global.getGyroMouseHorizontalAxis(deviceNumber) == 0 ? arg.sixAxis.gyroYawFull : arg.sixAxis.gyroRollFull; deltaY = -arg.sixAxis.gyroPitchFull; - tempDouble = arg.sixAxis.elapsed * 0.001 * 250.0; // Base default speed on 4 ms + //tempDouble = arg.sixAxis.elapsed * 0.001 * 200.0; // Base default speed on 5 ms + tempDouble = arg.sixAxis.elapsed * 200.0; // Base default speed on 5 ms gyroSmooth = Global.getGyroSmoothing(deviceNumber); double gyroSmoothWeight = 0.0; @@ -58,11 +62,11 @@ namespace DS4Windows } } - double tempAngle = System.Math.Atan2(-deltaY, deltaX); - double normX = System.Math.Abs(System.Math.Cos(tempAngle)); - double normY = System.Math.Abs(System.Math.Sin(tempAngle)); - int signX = System.Math.Sign(deltaX); - int signY = System.Math.Sign(deltaY); + double tempAngle = Math.Atan2(-deltaY, deltaX); + double normX = Math.Abs(Math.Cos(tempAngle)); + double normY = Math.Abs(Math.Sin(tempAngle)); + int signX = Math.Sign(deltaX); + int signY = Math.Sign(deltaY); if (deltaX == 0 || (hRemainder > 0 != deltaX > 0)) { @@ -74,12 +78,10 @@ namespace DS4Windows vRemainder = 0.0; } - int deadzone = GYRO_MOUSE_DEADZONE; - //int deadzone = 0; - int deadzoneX = (int)System.Math.Abs(normX * deadzone); - int deadzoneY = (int)System.Math.Abs(normY * deadzone); + int deadzoneX = (int)Math.Abs(normX * GYRO_MOUSE_DEADZONE); + int deadzoneY = (int)Math.Abs(normY * GYRO_MOUSE_DEADZONE); - if (System.Math.Abs(deltaX) > deadzoneX) + if (Math.Abs(deltaX) > deadzoneX) { deltaX -= signX * deadzoneX; } @@ -88,7 +90,7 @@ namespace DS4Windows deltaX = 0; } - if (System.Math.Abs(deltaY) > deadzoneY) + if (Math.Abs(deltaY) > deadzoneY) { deltaY -= signY * deadzoneY; } @@ -105,6 +107,10 @@ namespace DS4Windows { xMotion += hRemainder; } + else + { + hRemainder = 0.0; + } verticalScale = Global.getGyroSensVerticalScale(deviceNumber) * 0.01; double yMotion = deltaY != 0 ? (coefficient * verticalScale) * (deltaY * tempDouble) @@ -115,6 +121,10 @@ namespace DS4Windows { yMotion += vRemainder; } + else + { + vRemainder = 0.0; + } if (gyroSmooth) { @@ -129,7 +139,7 @@ namespace DS4Windows int idx = 0; for (int i = 0; i < SMOOTH_BUFFER_LEN; i++) { - idx = System.Math.Abs(smoothBufferTail - i - 1) % SMOOTH_BUFFER_LEN; + idx = (smoothBufferTail - i - 1 + SMOOTH_BUFFER_LEN) % SMOOTH_BUFFER_LEN; x_out += xSmoothBuffer[idx] * currentWeight; y_out += ySmoothBuffer[idx] * currentWeight; finalWeight += currentWeight; @@ -142,25 +152,18 @@ namespace DS4Windows yMotion = y_out; } + hRemainder = vRemainder = 0.0; if (xMotion != 0.0) { xAction = (int)xMotion; hRemainder = xMotion - xAction; } - else - { - hRemainder = 0.0; - } if (yMotion != 0.0) { yAction = (int)yMotion; vRemainder = yMotion - yAction; } - else - { - vRemainder = 0.0; - } int gyroInvert = Global.getGyroInvert(deviceNumber); if ((gyroInvert & 0x02) == 2) @@ -195,13 +198,13 @@ namespace DS4Windows } private byte lastTouchID; - public void touchesMoved(TouchpadEventArgs arg, bool dragging) + public void touchesMoved(TouchpadEventArgs arg, bool dragging, bool disableInvert = false) { int touchesLen = arg.touches.Length; if ((!dragging && touchesLen != 1) || (dragging && touchesLen < 1)) return; - int deltaX, deltaY; + int deltaX = 0, deltaY = 0; if (arg.touches[0].touchID != lastTouchID) { deltaX = deltaY = 0; @@ -209,56 +212,6 @@ namespace DS4Windows horizontalDirection = verticalDirection = Direction.Neutral; lastTouchID = arg.touches[0].touchID; } - else if (Global.TouchpadJitterCompensation[deviceNumber]) - { - // Often the DS4's internal jitter compensation kicks in and starts hiding changes, ironically creating jitter... - if (dragging && touchesLen > 1) - { - deltaX = arg.touches[1].deltaX; - deltaY = arg.touches[1].deltaY; - } - else - { - deltaX = arg.touches[0].deltaX; - deltaY = arg.touches[0].deltaY; - } - - // allow only very fine, slow motions, when changing direction, even from neutral - // TODO maybe just consume it completely? - if (deltaX <= -1) - { - if (horizontalDirection != Direction.Negative) - { - deltaX = -1; - horizontalRemainder = 0.0; - } - } - else if (deltaX >= 1) - { - if (horizontalDirection != Direction.Positive) - { - deltaX = 1; - horizontalRemainder = 0.0; - } - } - - if (deltaY <= -1) - { - if (verticalDirection != Direction.Negative) - { - deltaY = -1; - verticalRemainder = 0.0; - } - } - else if (deltaY >= 1) - { - if (verticalDirection != Direction.Positive) - { - deltaY = 1; - verticalRemainder = 0.0; - } - } - } else { if (dragging && touchesLen > 1) @@ -273,42 +226,67 @@ namespace DS4Windows } } - double coefficient = Global.TouchSensitivity[deviceNumber] * 0.01; - // Collect rounding errors instead of losing motion. - double xMotion = coefficient * deltaX; - if (xMotion > 0.0) + double tempAngle = Math.Atan2(-deltaY, deltaX); + double normX = Math.Abs(Math.Cos(tempAngle)); + double normY = Math.Abs(Math.Sin(tempAngle)); + int signX = Math.Sign(deltaX); + int signY = Math.Sign(deltaY); + double coefficient = Global.getTouchSensitivity(deviceNumber) * 0.01; + bool jitterCompenstation = Global.getTouchpadJitterCompensation(deviceNumber); + + double xMotion = deltaX != 0 ? + coefficient * deltaX + (normX * (TOUCHPAD_MOUSE_OFFSET * signX)) : 0.0; + + double yMotion = deltaY != 0 ? + coefficient * deltaY + (normY * (TOUCHPAD_MOUSE_OFFSET * signY)) : 0.0; + + if (jitterCompenstation) { - if (horizontalRemainder > 0.0) - xMotion += horizontalRemainder; + double absX = Math.Abs(xMotion); + if (absX <= normX * 0.34) + { + xMotion = signX * Math.Pow(absX / 0.34f, 1.44) * 0.34; + } + + double absY = Math.Abs(yMotion); + if (absY <= normY * 0.34) + { + yMotion = signY * Math.Pow(absY / 0.34f, 1.44) * 0.34; + } } - else if (xMotion < 0.0) + + // Collect rounding errors instead of losing motion. + if (xMotion > 0.0 && horizontalRemainder > 0.0) { - if (horizontalRemainder < 0.0) - xMotion += horizontalRemainder; + xMotion += horizontalRemainder; + } + else if (xMotion < 0.0 && horizontalRemainder < 0.0) + { + xMotion += horizontalRemainder; } int xAction = (int)xMotion; horizontalRemainder = xMotion - xAction; - double yMotion = coefficient * deltaY; - if (yMotion > 0.0) + if (yMotion > 0.0 && verticalRemainder > 0.0) { - if (verticalRemainder > 0.0) - yMotion += verticalRemainder; + yMotion += verticalRemainder; } - else if (yMotion < 0.0) + else if (yMotion < 0.0 && verticalRemainder < 0.0) { - if (verticalRemainder < 0.0) - yMotion += verticalRemainder; + yMotion += verticalRemainder; } int yAction = (int)yMotion; verticalRemainder = yMotion - yAction; - int touchpadInvert = tempInt = Global.getTouchpadInvert(deviceNumber); - if ((touchpadInvert & 0x02) == 2) - xAction *= -1; + if (disableInvert == false) + { + int touchpadInvert = tempInt = Global.getTouchpadInvert(deviceNumber); + if ((touchpadInvert & 0x02) == 2) + xAction *= -1; - if ((touchpadInvert & 0x01) == 1) - yAction *= -1; + if ((touchpadInvert & 0x01) == 1) + yAction *= -1; + } if (yAction != 0 || xAction != 0) InputMethods.MoveCursorBy(xAction, yAction); diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 3fa265c..ac35c57 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.IO; using System.Reflection; @@ -224,21 +225,6 @@ namespace DS4Windows } } - public class MultiValueDict : Dictionary> - { - public void Add(Key key, Value val) - { - List values = null; - if (!this.TryGetValue(key, out values)) - { - values = new List(); - this.Add(key, values); - } - - values.Add(val); - } - } - public class Global { protected static BackingStore m_Config = new BackingStore(); @@ -250,8 +236,9 @@ namespace DS4Windows public static string[] tempprofilename = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; public static bool[] tempprofileDistance = new bool[5] { false, false, false, false, false }; public static bool[] useDInputOnly = new bool[5] { true, true, true, true, true }; + public static bool[] linkedProfileCheck = new bool[4] { true, true, true, true }; - public static X360Controls[] defaultButtonMapping = { X360Controls.None, X360Controls.LXNeg, X360Controls.LXPos, + public static X360Controls[] defaultButtonMapping = { X360Controls.None, X360Controls.LXNeg, X360Controls.LXPos, X360Controls.LYNeg, X360Controls.LYPos, X360Controls.RXNeg, X360Controls.RXPos, X360Controls.RYNeg, X360Controls.RYPos, X360Controls.LB, X360Controls.LT, X360Controls.LS, X360Controls.RB, X360Controls.RT, X360Controls.RS, X360Controls.X, X360Controls.Y, X360Controls.B, X360Controls.A, X360Controls.DpadUp, X360Controls.DpadRight, X360Controls.DpadDown, @@ -281,6 +268,7 @@ namespace DS4Windows appdatapath = path; m_Config.m_Profile = appdatapath + "\\Profiles.xml"; m_Config.m_Actions = appdatapath + "\\Actions.xml"; + m_Config.m_linkedProfiles = Global.appdatapath + "\\LinkedProfiles.xml"; } /// @@ -572,6 +560,12 @@ namespace DS4Windows return m_Config.sATriggers[index]; } + public static int[][] TouchDisInvertTriggers => m_Config.touchDisInvertTriggers; + public static int[] getTouchDisInvertTriggers(int index) + { + return m_Config.touchDisInvertTriggers[index]; + } + public static int[] GyroSensitivity => m_Config.gyroSensitivity; public static int getGyroSensitivity(int index) { @@ -665,6 +659,10 @@ namespace DS4Windows public static bool[] LowerRCOn => m_Config.lowerRCOn; public static bool[] TouchpadJitterCompensation => m_Config.touchpadJitterCompensation; + public static bool getTouchpadJitterCompensation(int index) + { + return m_Config.touchpadJitterCompensation[index]; + } public static int[] TouchpadInvert => m_Config.touchpadInvert; public static int getTouchpadInvert(int index) @@ -890,6 +888,7 @@ namespace DS4Windows public static string[] LaunchProgram => m_Config.launchProgram; public static string[] ProfilePath => m_Config.profilePath; + public static string[] OlderProfilePath => m_Config.olderProfilePath; public static bool[] DistanceProfiles = m_Config.distanceProfiles; public static List[] ProfileActions => m_Config.profileActions; @@ -944,7 +943,8 @@ namespace DS4Windows return m_Config.containsCustomExtras[deviceNum]; } - public static void SaveAction(string name, string controls, int mode, string details, bool edit, string extras = "") + public static void SaveAction(string name, string controls, int mode, + string details, bool edit, string extras = "") { m_Config.SaveAction(name, controls, mode, details, edit, extras); Mapping.actionDone.Add(new Mapping.ActionState()); @@ -1035,44 +1035,45 @@ namespace DS4Windows return defaultButtonMapping[(int)dc]; } - /*public static X360Controls getCustomButton(int device, DS4Controls controlName) => m_Config.GetCustomButton(device, controlName); - - public static ushort getCustomKey(int device, DS4Controls controlName) => m_Config.GetCustomKey(device, controlName); - - public static string getCustomMacro(int device, DS4Controls controlName) => m_Config.GetCustomMacro(device, controlName); - - public static string getCustomExtras(int device, DS4Controls controlName) => m_Config.GetCustomExtras(device, controlName); - - public static DS4KeyType getCustomKeyType(int device, DS4Controls controlName) => m_Config.GetCustomKeyType(device, controlName); - - public static bool getHasCustomKeysorButtons(int device) => m_Config.customMapButtons[device].Count > 0 - || m_Config.customMapKeys[device].Count > 0; - - public static bool getHasCustomExtras(int device) => m_Config.customMapExtras[device].Count > 0; - public static Dictionary getCustomButtons(int device) => m_Config.customMapButtons[device]; - public static Dictionary getCustomKeys(int device) => m_Config.customMapKeys[device]; - public static Dictionary getCustomMacros(int device) => m_Config.customMapMacros[device]; - public static Dictionary getCustomExtras(int device) => m_Config.customMapExtras[device]; - public static Dictionary getCustomKeyTypes(int device) => m_Config.customMapKeyTypes[device]; + public static bool containsLinkedProfile(string serial) + { + string tempSerial = serial.Replace(":", string.Empty); + return m_Config.linkedProfiles.ContainsKey(tempSerial); + } + + public static string getLinkedProfile(string serial) + { + string temp = string.Empty; + string tempSerial = serial.Replace(":", string.Empty); + if (m_Config.linkedProfiles.ContainsKey(tempSerial)) + { + temp = m_Config.linkedProfiles[tempSerial]; + } + + return temp; + } + + public static void changeLinkedProfile(string serial, string profile) + { + string tempSerial = serial.Replace(":", string.Empty); + m_Config.linkedProfiles[tempSerial] = profile; + } + + public static void removeLinkedProfile(string serial) + { + string tempSerial = serial.Replace(":", string.Empty); + if (m_Config.linkedProfiles.ContainsKey(tempSerial)) + { + m_Config.linkedProfiles.Remove(tempSerial); + } + } - public static X360Controls getShiftCustomButton(int device, DS4Controls controlName) => m_Config.GetShiftCustomButton(device, controlName); - public static ushort getShiftCustomKey(int device, DS4Controls controlName) => m_Config.GetShiftCustomKey(device, controlName); - public static string getShiftCustomMacro(int device, DS4Controls controlName) => m_Config.GetShiftCustomMacro(device, controlName); - public static string getShiftCustomExtras(int device, DS4Controls controlName) => m_Config.GetShiftCustomExtras(device, controlName); - public static DS4KeyType getShiftCustomKeyType(int device, DS4Controls controlName) => m_Config.GetShiftCustomKeyType(device, controlName); - public static bool getHasShiftCustomKeysorButtons(int device) => m_Config.shiftCustomMapButtons[device].Count > 0 - || m_Config.shiftCustomMapKeys[device].Count > 0; - public static bool getHasShiftCustomExtras(int device) => m_Config.shiftCustomMapExtras[device].Count > 0; - public static Dictionary getShiftCustomButtons(int device) => m_Config.shiftCustomMapButtons[device]; - public static Dictionary getShiftCustomKeys(int device) => m_Config.shiftCustomMapKeys[device]; - public static Dictionary getShiftCustomMacros(int device) => m_Config.shiftCustomMapMacros[device]; - public static Dictionary getShiftCustomExtras(int device) => m_Config.shiftCustomMapExtras[device]; - public static Dictionary getShiftCustomKeyTypes(int device) => m_Config.shiftCustomMapKeyTypes[device]; */ public static bool Load() => m_Config.Load(); - public static void LoadProfile(int device, bool launchprogram, ControlService control, bool xinputChange = true) + public static void LoadProfile(int device, bool launchprogram, ControlService control, + bool xinputChange = true, bool postLoad = true) { - m_Config.LoadProfile(device, launchprogram, control, "", xinputChange); + m_Config.LoadProfile(device, launchprogram, control, "", xinputChange, postLoad); tempprofilename[device] = string.Empty; tempprofileDistance[device] = false; } @@ -1095,6 +1096,16 @@ namespace DS4Windows m_Config.SaveProfile(device, propath); } + public static bool SaveLinkedProfiles() + { + return m_Config.SaveLinkedProfiles(); + } + + public static bool LoadLinkedProfiles() + { + return m_Config.LoadLinkedProfiles(); + } + private static byte applyRatio(byte b1, byte b2, double r) { if (r > 100.0) @@ -1187,60 +1198,62 @@ namespace DS4Windows } } - public class BackingStore { //public String m_Profile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool" + "\\Profiles.xml"; public String m_Profile = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + "\\Profiles.xml"; public String m_Actions = Global.appdatapath + "\\Actions.xml"; + public string m_linkedProfiles = Global.appdatapath + "\\LinkedProfiles.xml"; protected XmlDocument m_Xdoc = new XmlDocument(); // fifth value used for options, not fifth controller - public int[] buttonMouseSensitivity = { 25, 25, 25, 25, 25 }; + public int[] buttonMouseSensitivity = new int[5] { 25, 25, 25, 25, 25 }; - public bool[] flushHIDQueue = { false, false, false, false, false }; - public bool[] enableTouchToggle = { true, true, true, true, true }; - public int[] idleDisconnectTimeout = { 0, 0, 0, 0, 0 }; - public bool[] touchpadJitterCompensation = { true, true, true, true, true }; - public bool[] lowerRCOn = { false, false, false, false, false }; - public bool[] ledAsBattery = { false, false, false, false, false }; - public byte[] flashType = { 0, 0, 0, 0, 0 }; - public string[] profilePath = { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + public bool[] flushHIDQueue = new bool[5] { false, false, false, false, false }; + public bool[] enableTouchToggle = new bool[5] { true, true, true, true, true }; + public int[] idleDisconnectTimeout = new int[5] { 0, 0, 0, 0, 0 }; + public bool[] touchpadJitterCompensation = new bool[5] { true, true, true, true, true }; + public bool[] lowerRCOn = new bool[5] { false, false, false, false, false }; + public bool[] ledAsBattery = new bool[5] { false, false, false, false, false }; + public byte[] flashType = new byte[5] { 0, 0, 0, 0, 0 }; + public string[] profilePath = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + public string[] olderProfilePath = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + public Dictionary linkedProfiles = new Dictionary(); // Cache properties instead of performing a string comparison every frame - public bool[] distanceProfiles = { false, false, false, false, false }; - public Byte[] rumble = { 100, 100, 100, 100, 100 }; - public Byte[] touchSensitivity = { 100, 100, 100, 100, 100 }; - public Byte[] l2Deadzone = { 0, 0, 0, 0, 0 }, r2Deadzone = { 0, 0, 0, 0, 0 }; - public int[] LSDeadzone = { 0, 0, 0, 0, 0 }, RSDeadzone = { 0, 0, 0, 0, 0 }; - public int[] LSAntiDeadzone = { 0, 0, 0, 0, 0 }, RSAntiDeadzone = { 0, 0, 0, 0, 0 }; - public int[] LSMaxzone = { 100, 100, 100, 100, 100 }, RSMaxzone = { 100, 100, 100, 100, 100 }; - public int[] l2AntiDeadzone = { 0, 0, 0, 0, 0 }, r2AntiDeadzone = { 0, 0, 0, 0, 0 }; - public int[] l2Maxzone = { 100, 100, 100, 100, 100 }, r2Maxzone = { 100, 100, 100, 100, 100 }; - public double[] LSRotation = { 0.0, 0.0, 0.0, 0.0, 0.0 }, RSRotation = { 0.0, 0.0, 0.0, 0.0, 0.0 }; - public double[] SXDeadzone = { 0.25, 0.25, 0.25, 0.25, 0.25 }, SZDeadzone = { 0.25, 0.25, 0.25, 0.25, 0.25 }; + public bool[] distanceProfiles = new bool[5] { false, false, false, false, false }; + public Byte[] rumble = new Byte[5] { 100, 100, 100, 100, 100 }; + public Byte[] touchSensitivity = new Byte[5] { 100, 100, 100, 100, 100 }; + public Byte[] l2Deadzone = new Byte[5] { 0, 0, 0, 0, 0 }, r2Deadzone = new Byte[5] { 0, 0, 0, 0, 0 }; + public int[] LSDeadzone = new int[5] { 0, 0, 0, 0, 0 }, RSDeadzone = new int[5] { 0, 0, 0, 0, 0 }; + public int[] LSAntiDeadzone = new int[5] { 0, 0, 0, 0, 0 }, RSAntiDeadzone = new int[5] { 0, 0, 0, 0, 0 }; + public int[] LSMaxzone = new int[5] { 100, 100, 100, 100, 100 }, RSMaxzone = new int[5] { 100, 100, 100, 100, 100 }; + public int[] l2AntiDeadzone = new int[5] { 0, 0, 0, 0, 0 }, r2AntiDeadzone = new int[5] { 0, 0, 0, 0, 0 }; + public int[] l2Maxzone = new int[5] { 100, 100, 100, 100, 100 }, r2Maxzone = new int[5] { 100, 100, 100, 100, 100 }; + public double[] LSRotation = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 }, RSRotation = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 }; + public double[] SXDeadzone = new double[5] { 0.25, 0.25, 0.25, 0.25, 0.25 }, SZDeadzone = new double[5] { 0.25, 0.25, 0.25, 0.25, 0.25 }; public double[] SXMaxzone = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }, SZMaxzone = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }; public double[] SXAntiDeadzone = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 }, SZAntiDeadzone = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 }; - public double[] l2Sens = { 1, 1, 1, 1, 1 }, r2Sens = { 1, 1, 1, 1, 1 }; - public double[] LSSens = { 1, 1, 1, 1, 1 }, RSSens = { 1, 1, 1, 1, 1 }; - public double[] SXSens = { 1, 1, 1, 1, 1 }, SZSens = { 1, 1, 1, 1, 1 }; - public Byte[] tapSensitivity = { 0, 0, 0, 0, 0 }; - public bool[] doubleTap = { false, false, false, false, false }; - public int[] scrollSensitivity = { 0, 0, 0, 0, 0 }; - public int[] touchpadInvert = { 0, 0, 0, 0, 0 }; - public double[] rainbow = { 0, 0, 0, 0, 0 }; - public int[] flashAt = { 0, 0, 0, 0, 0 }; - public bool[] mouseAccel = { true, true, true, true, true }; - public int[] btPollRate = { 4, 4, 4, 4, 4 }; - public int[] lsOutCurveMode = { 0, 0, 0, 0, 0 }; - public int[] rsOutCurveMode = { 0, 0, 0, 0, 0 }; + public double[] l2Sens = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }, r2Sens = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }; + public double[] LSSens = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }, RSSens = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }; + public double[] SXSens = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }, SZSens = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }; + public Byte[] tapSensitivity = new Byte[5] { 0, 0, 0, 0, 0 }; + public bool[] doubleTap = new bool[5] { false, false, false, false, false }; + public int[] scrollSensitivity = new int[5] { 0, 0, 0, 0, 0 }; + public int[] touchpadInvert = new int[5] { 0, 0, 0, 0, 0 }; + public double[] rainbow = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 }; + public int[] flashAt = new int[5] { 0, 0, 0, 0, 0 }; + public bool[] mouseAccel = new bool[5] { true, true, true, true, true }; + public int[] btPollRate = new int[5] { 4, 4, 4, 4, 4 }; + public int[] lsOutCurveMode = new int[5] { 0, 0, 0, 0, 0 }; + public int[] rsOutCurveMode = new int[5] { 0, 0, 0, 0, 0 }; public int[] l2OutCurveMode = new int[5] { 0, 0, 0, 0, 0 }; public int[] r2OutCurveMode = new int[5] { 0, 0, 0, 0, 0 }; public int[] sxOutCurveMode = new int[5] { 0, 0, 0, 0, 0 }; public int[] szOutCurveMode = new int[5] { 0, 0, 0, 0, 0 }; - public DS4Color[] m_LowLeds = new DS4Color[] + public DS4Color[] m_LowLeds = new DS4Color[5] { new DS4Color(Color.Black), new DS4Color(Color.Black), @@ -1248,7 +1261,7 @@ namespace DS4Windows new DS4Color(Color.Black), new DS4Color(Color.Black) }; - public DS4Color[] m_Leds = new DS4Color[] + public DS4Color[] m_Leds = new DS4Color[5] { new DS4Color(Color.Blue), new DS4Color(Color.Red), @@ -1256,7 +1269,7 @@ namespace DS4Windows new DS4Color(Color.Pink), new DS4Color(Color.White) }; - public DS4Color[] m_ChargingLeds = new DS4Color[] + public DS4Color[] m_ChargingLeds = new DS4Color[5] { new DS4Color(Color.Black), new DS4Color(Color.Black), @@ -1264,7 +1277,7 @@ namespace DS4Windows new DS4Color(Color.Black), new DS4Color(Color.Black) }; - public DS4Color[] m_FlashLeds = new DS4Color[] + public DS4Color[] m_FlashLeds = new DS4Color[5] { new DS4Color(Color.Black), new DS4Color(Color.Black), @@ -1272,8 +1285,8 @@ namespace DS4Windows new DS4Color(Color.Black), new DS4Color(Color.Black) }; - public bool[] useCustomLeds = new bool[] { false, false, false, false, false }; - public DS4Color[] m_CustomLeds = new DS4Color[] + public bool[] useCustomLeds = new bool[5] { false, false, false, false, false }; + public DS4Color[] m_CustomLeds = new DS4Color[5] { new DS4Color(Color.Black), new DS4Color(Color.Black), @@ -1281,15 +1294,18 @@ namespace DS4Windows new DS4Color(Color.Black), new DS4Color(Color.Black) }; - public int[] chargingType = { 0, 0, 0, 0, 0 }; - public string[] launchProgram = { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; - public bool[] dinputOnly = { false, false, false, false, false }; - public bool[] startTouchpadOff = { false, false, false, false, false }; - public bool[] useTPforControls = { false, false, false, false, false }; - public bool[] useSAforMouse = { false, false, false, false, false }; - public string[] sATriggers = { "", "", "", "", "" }; - public int[] lsCurve = { 0, 0, 0, 0, 0 }; - public int[] rsCurve = { 0, 0, 0, 0, 0 }; + + public int[] chargingType = new int[5] { 0, 0, 0, 0, 0 }; + public string[] launchProgram = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + public bool[] dinputOnly = new bool[5] { false, false, false, false, false }; + public bool[] startTouchpadOff = new bool[5] { false, false, false, false, false }; + public bool[] useTPforControls = new bool[5] { false, false, false, false, false }; + public bool[] useSAforMouse = new bool[5] { false, false, false, false, false }; + public string[] sATriggers = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + public int[][] touchDisInvertTriggers = new int[5][] { new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, + new int[1] { -1 }, new int[1] { -1 } }; + public int[] lsCurve = new int[5] { 0, 0, 0, 0, 0 }; + public int[] rsCurve = new int[5] { 0, 0, 0, 0, 0 }; public Boolean useExclusiveMode = false; public Int32 formWidth = 782; public Int32 formHeight = 550; @@ -1304,38 +1320,36 @@ namespace DS4Windows public int firstXinputPort = 1; public bool closeMini = false; public List actions = new List(); - public List[] ds4settings = { new List(), new List(), new List(), new List(), new List() }; - /*public Dictionary[] customMapKeyTypes = { null, null, null, null, null }; - public Dictionary[] customMapKeys = { null, null, null, null, null }; - public Dictionary[] customMapMacros = { null, null, null, null, null }; - public Dictionary[] customMapButtons = { null, null, null, null, null }; - public Dictionary[] customMapExtras = { null, null, null, null, null }; + public List[] ds4settings = new List[5] + { new List(), new List(), new List(), + new List(), new List() }; + + public List[] profileActions = new List[5] { null, null, null, null, null }; + public int[] profileActionCount = new int[5] { 0, 0, 0, 0, 0 }; + public Dictionary[] profileActionDict = new Dictionary[5] + { new Dictionary(), new Dictionary(), new Dictionary(), + new Dictionary(), new Dictionary() }; + + public Dictionary[] profileActionIndexDict = new Dictionary[5] + { new Dictionary(), new Dictionary(), new Dictionary(), + new Dictionary(), new Dictionary() }; - public Dictionary[] shiftCustomMapKeyTypes = { null, null, null, null, null }; - public Dictionary[] shiftCustomMapKeys = { null, null, null, null, null }; - public Dictionary[] shiftCustomMapMacros = { null, null, null, null, null }; - public Dictionary[] shiftCustomMapButtons = { null, null, null, null, null }; - public Dictionary[] shiftCustomMapExtras = { null, null, null, null, null };*/ - public List[] profileActions = { null, null, null, null, null }; - public int[] profileActionCount = { 0, 0, 0, 0, 0 }; - public Dictionary[] profileActionDict = { new Dictionary(), new Dictionary(), new Dictionary(), new Dictionary(), new Dictionary() }; - public Dictionary[] profileActionIndexDict = { new Dictionary(), new Dictionary(), new Dictionary(), new Dictionary(), new Dictionary() }; public bool downloadLang = true; public bool useWhiteIcon; public bool flashWhenLate = true; public int flashWhenLateAt = 20; // Cache whether profile has custom action - public bool[] containsCustomAction = { false, false, false, false, false }; + public bool[] containsCustomAction = new bool[5] { false, false, false, false, false }; // Cache whether profile has custom extras - public bool[] containsCustomExtras = { false, false, false, false, false }; + public bool[] containsCustomExtras = new bool[5] { false, false, false, false, false }; - public int[] gyroSensitivity = { 100, 100, 100, 100, 100 }; - public int[] gyroSensVerticalScale = { 100, 100, 100, 100, 100 }; - public int[] gyroInvert = { 0, 0, 0, 0, 0 }; - public bool[] gyroTriggerTurns = { true, true, true, true, true }; - public bool[] gyroSmoothing = { false, false, false, false, false }; - public double[] gyroSmoothWeight = { 0.5, 0.5, 0.5, 0.5, 0.5 }; + public int[] gyroSensitivity = new int[5] { 100, 100, 100, 100, 100 }; + public int[] gyroSensVerticalScale = new int[5] { 100, 100, 100, 100, 100 }; + public int[] gyroInvert = new int[5] { 0, 0, 0, 0, 0 }; + public bool[] gyroTriggerTurns = new bool[5] { true, true, true, true, true }; + public bool[] gyroSmoothing = new bool[5] { false, false, false, false, false }; + public double[] gyroSmoothWeight = new double[5] { 0.5, 0.5, 0.5, 0.5, 0.5 }; public int[] gyroMouseHorizontalAxis = new int[5] { 0, 0, 0, 0, 0 }; bool tempBool = false; @@ -1350,94 +1364,12 @@ namespace DS4Windows ds4settings[i].Add(new DS4ControlSettings(dc)); } - /*customMapKeyTypes[i] = new Dictionary(); - customMapKeys[i] = new Dictionary(); - customMapMacros[i] = new Dictionary(); - customMapButtons[i] = new Dictionary(); - customMapExtras[i] = new Dictionary(); - - shiftCustomMapKeyTypes[i] = new Dictionary(); - shiftCustomMapKeys[i] = new Dictionary(); - shiftCustomMapMacros[i] = new Dictionary(); - shiftCustomMapButtons[i] = new Dictionary(); - shiftCustomMapExtras[i] = new Dictionary();*/ - profileActions[i] = new List(); profileActions[i].Add("Disconnect Controller"); profileActionCount[i] = profileActions[i].Count; } } - /*public X360Controls GetCustomButton(int device, DS4Controls controlName) - { - if (customMapButtons[device].ContainsKey(controlName)) - return customMapButtons[device][controlName]; - else return X360Controls.None; - } - public UInt16 GetCustomKey(int device, DS4Controls controlName) - { - if (customMapKeys[device].ContainsKey(controlName)) - return customMapKeys[device][controlName]; - else return 0; - } - public string GetCustomMacro(int device, DS4Controls controlName) - { - if (customMapMacros[device].ContainsKey(controlName)) - return customMapMacros[device][controlName]; - else return "0"; - } - public string GetCustomExtras(int device, DS4Controls controlName) - { - if (customMapExtras[device].ContainsKey(controlName)) - return customMapExtras[device][controlName]; - else return "0"; - } - public DS4KeyType GetCustomKeyType(int device, DS4Controls controlName) - { - try - { - if (customMapKeyTypes[device].ContainsKey(controlName)) - return customMapKeyTypes[device][controlName]; - else return 0; - } - catch { return 0; } - } - - public X360Controls GetShiftCustomButton(int device, DS4Controls controlName) - { - if (shiftCustomMapButtons[device].ContainsKey(controlName)) - return shiftCustomMapButtons[device][controlName]; - else return X360Controls.None; - } - public UInt16 GetShiftCustomKey(int device, DS4Controls controlName) - { - if (shiftCustomMapKeys[device].ContainsKey(controlName)) - return shiftCustomMapKeys[device][controlName]; - else return 0; - } - public string GetShiftCustomMacro(int device, DS4Controls controlName) - { - if (shiftCustomMapMacros[device].ContainsKey(controlName)) - return shiftCustomMapMacros[device][controlName]; - else return "0"; - } - public string GetShiftCustomExtras(int device, DS4Controls controlName) - { - if (customMapExtras[device].ContainsKey(controlName)) - return customMapExtras[device][controlName]; - else return "0"; - } - public DS4KeyType GetShiftCustomKeyType(int device, DS4Controls controlName) - { - try - { - if (shiftCustomMapKeyTypes[device].ContainsKey(controlName)) - return shiftCustomMapKeyTypes[device][controlName]; - else return 0; - } - catch { return 0; } - }*/ - private string stickOutputCurveString(int id) { string result = "linear"; @@ -1583,6 +1515,12 @@ namespace DS4Windows XmlNode xmlUseTPforControls = m_Xdoc.CreateNode(XmlNodeType.Element, "UseTPforControls", null); xmlUseTPforControls.InnerText = useTPforControls[device].ToString(); Node.AppendChild(xmlUseTPforControls); XmlNode xmlUseSAforMouse = m_Xdoc.CreateNode(XmlNodeType.Element, "UseSAforMouse", null); xmlUseSAforMouse.InnerText = useSAforMouse[device].ToString(); Node.AppendChild(xmlUseSAforMouse); XmlNode xmlSATriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "SATriggers", null); xmlSATriggers.InnerText = sATriggers[device].ToString(); Node.AppendChild(xmlSATriggers); + + XmlNode xmlTouchDisInvTriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "TouchDisInvTriggers", null); + string tempTouchDisInv = string.Join(",", touchDisInvertTriggers[device]); + xmlTouchDisInvTriggers.InnerText = tempTouchDisInv; + Node.AppendChild(xmlTouchDisInvTriggers); + XmlNode xmlGyroSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroSensitivity", null); xmlGyroSensitivity.InnerText = gyroSensitivity[device].ToString(); Node.AppendChild(xmlGyroSensitivity); XmlNode xmlGyroSensVerticalScale = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroSensVerticalScale", null); xmlGyroSensVerticalScale.InnerText = gyroSensVerticalScale[device].ToString(); Node.AppendChild(xmlGyroSensVerticalScale); XmlNode xmlGyroInvert = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroInvert", null); xmlGyroInvert.InnerText = gyroInvert[device].ToString(); Node.AppendChild(xmlGyroInvert); @@ -1785,104 +1723,7 @@ namespace DS4Windows NodeShiftControl.AppendChild(ShiftKeyType); if (ShiftExtras.HasChildNodes) NodeShiftControl.AppendChild(ShiftExtras); - /*else if (xmlControls != null) - { - Node.AppendChild(xmlControls); - }*/ - /*if (shiftModifier[device] > 0) - { - XmlNode NodeShiftControl = m_Xdoc.CreateNode(XmlNodeType.Element, "ShiftControl", null); - - XmlNode ShiftKey = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null); - XmlNode ShiftMacro = m_Xdoc.CreateNode(XmlNodeType.Element, "Macro", null); - XmlNode ShiftKeyType = m_Xdoc.CreateNode(XmlNodeType.Element, "KeyType", null); - XmlNode ShiftButton = m_Xdoc.CreateNode(XmlNodeType.Element, "Button", null); - XmlNode ShiftExtras = m_Xdoc.CreateNode(XmlNodeType.Element, "Extras", null); - if (shiftbuttons != null) - { - foreach (var button in shiftbuttons) - { - // Save even if string (for xbox controller buttons) - if (button.Tag != null) - { - XmlNode buttonNode; - string keyType = String.Empty; - if (button.Tag is KeyValuePair) - if (((KeyValuePair)button.Tag).Key == "Unbound") - keyType += DS4KeyType.Unbound; - - if (button.Font.Strikeout) - keyType += DS4KeyType.HoldMacro; - if (button.Font.Underline) - keyType += DS4KeyType.Macro; - if (button.Font.Italic) - keyType += DS4KeyType.Toggle; - if (button.Font.Bold) - keyType += DS4KeyType.ScanCode; - if (keyType != String.Empty) - { - buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null); - buttonNode.InnerText = keyType; - ShiftKeyType.AppendChild(buttonNode); - } - - string[] extras; - buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null); - if (button.Tag is KeyValuePair, string> || button.Tag is KeyValuePair || button.Tag is KeyValuePair) - { - KeyValuePair tag = (KeyValuePair)button.Tag; - int[] ii = tag.Key; - buttonNode.InnerText = string.Join("/", ii); - ShiftMacro.AppendChild(buttonNode); - extras = tag.Value.Split(','); - } - else if (button.Tag is KeyValuePair || button.Tag is KeyValuePair || button.Tag is KeyValuePair) - { - KeyValuePair tag = (KeyValuePair)button.Tag; - buttonNode.InnerText = tag.Key.ToString(); - ShiftKey.AppendChild(buttonNode); - extras = tag.Value.Split(','); - } - else if (button.Tag is KeyValuePair) - { - KeyValuePair tag = (KeyValuePair)button.Tag; - buttonNode.InnerText = tag.Key; - ShiftButton.AppendChild(buttonNode); - extras = tag.Value.Split(','); - } - else - { - KeyValuePair tag = (KeyValuePair)button.Tag; - extras = tag.Value.Split(','); - } - bool hasvalue = false; - foreach (string s in extras) - if (s != "0") - { - hasvalue = true; - break; - } - if (hasvalue && !string.IsNullOrEmpty(String.Join(",", extras))) - { - XmlNode extraNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null); - extraNode.InnerText = String.Join(",", extras); - ShiftExtras.AppendChild(extraNode); - } - } - } - Node.AppendChild(NodeShiftControl); - if (ShiftButton.HasChildNodes) - NodeShiftControl.AppendChild(ShiftButton); - if (ShiftMacro.HasChildNodes) - NodeShiftControl.AppendChild(ShiftMacro); - if (ShiftKey.HasChildNodes) - NodeShiftControl.AppendChild(ShiftKey); - if (ShiftKeyType.HasChildNodes) - NodeShiftControl.AppendChild(ShiftKeyType); - } - else if (xmlShiftControls != null) - Node.AppendChild(xmlShiftControls); - }*/ + m_Xdoc.AppendChild(Node); m_Xdoc.Save(path); } @@ -1892,7 +1733,6 @@ namespace DS4Windows public DS4Controls getDS4ControlsByName(string key) { - if (!key.StartsWith("bn")) return (DS4Controls)Enum.Parse(typeof(DS4Controls), key, true); @@ -2133,7 +1973,7 @@ namespace DS4Windows } public bool LoadProfile(int device, bool launchprogram, ControlService control, - string propath = "", bool xinputChange = true) + string propath = "", bool xinputChange = true, bool postLoad = true) { bool Loaded = true; Dictionary customMapKeyTypes = new Dictionary(); @@ -2556,6 +2396,21 @@ namespace DS4Windows try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SATriggers"); sATriggers[device] = Item.InnerText; } catch { sATriggers[device] = ""; missingSetting = true; } + try { + Item = m_Xdoc.SelectSingleNode("/" + rootname + "/TouchDisInvTriggers"); + string[] triggers = Item.InnerText.Split(','); + int temp = -1; + List tempIntList = new List(); + for (int i = 0, arlen = triggers.Length; i < arlen; i++) + { + if (int.TryParse(triggers[i], out temp)) + tempIntList.Add(temp); + } + + touchDisInvertTriggers[device] = tempIntList.ToArray(); + } + catch { touchDisInvertTriggers[device] = new int[1] { -1 }; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroSensitivity"); int.TryParse(Item.InnerText, out gyroSensitivity[device]); } catch { gyroSensitivity[device] = 100; missingSetting = true; } @@ -2821,7 +2676,7 @@ namespace DS4Windows // If a device exists, make sure to transfer relevant profile device // options to device instance - if (device < 4) + if (postLoad && device < 4) { DS4Device tempDev = control.DS4Controllers[device]; if (tempDev != null) @@ -2837,119 +2692,6 @@ namespace DS4Windows return Loaded; } - public void LoadButtons(System.Windows.Forms.Control[] buttons, string control, Dictionary customMapKeyTypes, - Dictionary customMapKeys, Dictionary customMapButtons, Dictionary customMapMacros, Dictionary customMapExtras) - { - XmlNode Item; - DS4KeyType keyType; - UInt16 wvk; - string rootname = "DS4Windows"; - foreach (var button in buttons) - try - { - if (m_Xdoc.SelectSingleNode(rootname) == null) - { - rootname = "ScpControl"; - } - //bool foundBinding = false; - button.Font = new Font(button.Font, FontStyle.Regular); - Item = m_Xdoc.SelectSingleNode(String.Format("/" + rootname + "/" + control + "/KeyType/{0}", button.Name)); - if (Item != null) - { - //foundBinding = true; - keyType = DS4KeyType.None; - if (Item.InnerText.Contains(DS4KeyType.Unbound.ToString())) - { - keyType = DS4KeyType.Unbound; - button.Tag = "Unbound"; - button.Text = "Unbound"; - } - else - { - bool SC = Item.InnerText.Contains(DS4KeyType.ScanCode.ToString()); - bool TG = Item.InnerText.Contains(DS4KeyType.Toggle.ToString()); - bool MC = Item.InnerText.Contains(DS4KeyType.Macro.ToString()); - bool MR = Item.InnerText.Contains(DS4KeyType.HoldMacro.ToString()); - button.Font = new Font(button.Font, - (SC ? FontStyle.Bold : FontStyle.Regular) | (TG ? FontStyle.Italic : FontStyle.Regular) | - (MC ? FontStyle.Underline : FontStyle.Regular) | (MR ? FontStyle.Strikeout : FontStyle.Regular)); - if (Item.InnerText.Contains(DS4KeyType.ScanCode.ToString())) - keyType |= DS4KeyType.ScanCode; - if (Item.InnerText.Contains(DS4KeyType.Toggle.ToString())) - keyType |= DS4KeyType.Toggle; - if (Item.InnerText.Contains(DS4KeyType.Macro.ToString())) - keyType |= DS4KeyType.Macro; - } - if (keyType != DS4KeyType.None) - customMapKeyTypes.Add(getDS4ControlsByName(Item.Name), keyType); - } - string extras; - Item = m_Xdoc.SelectSingleNode(String.Format("/" + rootname + "/" + control + "/Extras/{0}", button.Name)); - if (Item != null) - { - if (Item.InnerText != string.Empty) - { - extras = Item.InnerText; - customMapExtras.Add(getDS4ControlsByName(button.Name), Item.InnerText); - } - else - { - m_Xdoc.RemoveChild(Item); - extras = "0,0,0,0,0,0,0,0"; - } - } - else - extras = "0,0,0,0,0,0,0,0"; - Item = m_Xdoc.SelectSingleNode(String.Format("/" + rootname + "/" + control + "/Macro/{0}", button.Name)); - if (Item != null) - { - string[] splitter = Item.InnerText.Split('/'); - int[] keys = new int[splitter.Length]; - for (int i = 0; i < keys.Length; i++) - { - keys[i] = int.Parse(splitter[i]); - if (keys[i] < 255) splitter[i] = ((System.Windows.Forms.Keys)keys[i]).ToString(); - else if (keys[i] == 256) splitter[i] = "Left Mouse Button"; - else if (keys[i] == 257) splitter[i] = "Right Mouse Button"; - else if (keys[i] == 258) splitter[i] = "Middle Mouse Button"; - else if (keys[i] == 259) splitter[i] = "4th Mouse Button"; - else if (keys[i] == 260) splitter[i] = "5th Mouse Button"; - else if (keys[i] > 300) splitter[i] = "Wait " + (keys[i] - 300) + "ms"; - } - button.Text = "Macro"; - button.Tag = new KeyValuePair(keys, extras); - customMapMacros.Add(getDS4ControlsByName(button.Name), Item.InnerText); - } - else if (m_Xdoc.SelectSingleNode(String.Format("/" + rootname + "/" + control + "/Key/{0}", button.Name)) != null) - { - Item = m_Xdoc.SelectSingleNode(String.Format("/" + rootname + "/" + control + "/Key/{0}", button.Name)); - if (UInt16.TryParse(Item.InnerText, out wvk)) - { - //foundBinding = true; - customMapKeys.Add(getDS4ControlsByName(Item.Name), wvk); - button.Tag = new KeyValuePair(wvk, extras); - button.Text = ((System.Windows.Forms.Keys)wvk).ToString(); - } - } - else if (m_Xdoc.SelectSingleNode(String.Format("/" + rootname + "/" + control + "/Button/{0}", button.Name)) != null) - { - Item = m_Xdoc.SelectSingleNode(String.Format("/" + rootname + "/" + control + "/Button/{0}", button.Name)); - //foundBinding = true; - button.Tag = new KeyValuePair(Item.InnerText, extras); - button.Text = Item.InnerText; - customMapButtons.Add(getDS4ControlsByName(button.Name), getX360ControlsByName(Item.InnerText)); - } - else - { - button.Tag = new KeyValuePair(null, extras); - } - } - catch - { - - } - } - public bool Load() { bool Loaded = true; @@ -2977,32 +2719,40 @@ namespace DS4Windows { distanceProfiles[0] = true; } + + olderProfilePath[0] = profilePath[0]; } - catch { profilePath[0] = string.Empty; distanceProfiles[0] = false; missingSetting = true; } + catch { profilePath[0] = olderProfilePath[0] = string.Empty; distanceProfiles[0] = false; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/Profile/Controller2"); profilePath[1] = Item.InnerText; if (profilePath[1].ToLower().Contains("distance")) { distanceProfiles[1] = true; } + + olderProfilePath[1] = profilePath[1]; } - catch { profilePath[1] = string.Empty; distanceProfiles[1] = false; missingSetting = true; } + catch { profilePath[1] = olderProfilePath[1] = string.Empty; distanceProfiles[1] = false; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/Profile/Controller3"); profilePath[2] = Item.InnerText; if (profilePath[2].ToLower().Contains("distance")) { distanceProfiles[2] = true; } + + olderProfilePath[2] = profilePath[2]; } - catch { profilePath[2] = string.Empty; distanceProfiles[2] = false; missingSetting = true; } + catch { profilePath[2] = olderProfilePath[2] = string.Empty; distanceProfiles[2] = false; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/Profile/Controller4"); profilePath[3] = Item.InnerText; if (profilePath[3].ToLower().Contains("distance")) { distanceProfiles[3] = true; } + + olderProfilePath[3] = profilePath[3]; } - catch { profilePath[3] = string.Empty; distanceProfiles[3] = false; missingSetting = true; } + catch { profilePath[3] = olderProfilePath[3] = string.Empty; distanceProfiles[3] = false; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/Profile/LastChecked"); DateTime.TryParse(Item.InnerText, out lastChecked); } catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/Profile/CheckWhen"); Int32.TryParse(Item.InnerText, out CheckWhen); } @@ -3080,10 +2830,10 @@ namespace DS4Windows XmlNode xmlFormWidth = m_Xdoc.CreateNode(XmlNodeType.Element, "formWidth", null); xmlFormWidth.InnerText = formWidth.ToString(); Node.AppendChild(xmlFormWidth); XmlNode xmlFormHeight = m_Xdoc.CreateNode(XmlNodeType.Element, "formHeight", null); xmlFormHeight.InnerText = formHeight.ToString(); Node.AppendChild(xmlFormHeight); - XmlNode xmlController1 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller1", null); xmlController1.InnerText = profilePath[0]; Node.AppendChild(xmlController1); - XmlNode xmlController2 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller2", null); xmlController2.InnerText = profilePath[1]; Node.AppendChild(xmlController2); - XmlNode xmlController3 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller3", null); xmlController3.InnerText = profilePath[2]; Node.AppendChild(xmlController3); - XmlNode xmlController4 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller4", null); xmlController4.InnerText = profilePath[3]; Node.AppendChild(xmlController4); + XmlNode xmlController1 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller1", null); xmlController1.InnerText = !Global.linkedProfileCheck[0] ? profilePath[0] : olderProfilePath[0]; Node.AppendChild(xmlController1); + XmlNode xmlController2 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller2", null); xmlController2.InnerText = !Global.linkedProfileCheck[1] ? profilePath[1] : olderProfilePath[1]; Node.AppendChild(xmlController2); + XmlNode xmlController3 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller3", null); xmlController3.InnerText = !Global.linkedProfileCheck[2] ? profilePath[2] : olderProfilePath[2]; Node.AppendChild(xmlController3); + XmlNode xmlController4 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller4", null); xmlController4.InnerText = !Global.linkedProfileCheck[3] ? profilePath[3] : olderProfilePath[3]; Node.AppendChild(xmlController4); XmlNode xmlLastChecked = m_Xdoc.CreateNode(XmlNodeType.Element, "LastChecked", null); xmlLastChecked.InnerText = lastChecked.ToString(); Node.AppendChild(xmlLastChecked); XmlNode xmlCheckWhen = m_Xdoc.CreateNode(XmlNodeType.Element, "CheckWhen", null); xmlCheckWhen.InnerText = CheckWhen.ToString(); Node.AppendChild(xmlCheckWhen); @@ -3116,8 +2866,6 @@ namespace DS4Windows return Saved; } - - private void CreateAction() { XmlDocument m_Xdoc = new XmlDocument(); @@ -3319,6 +3067,105 @@ namespace DS4Windows return saved; } + public bool createLinkedProfiles() + { + bool saved = true; + XmlDocument m_Xdoc = new XmlDocument(); + XmlNode Node; + + Node = m_Xdoc.CreateXmlDeclaration("1.0", "utf-8", string.Empty); + m_Xdoc.AppendChild(Node); + + Node = m_Xdoc.CreateComment(string.Format(" Mac Address and Profile Linking Data. {0} ", DateTime.Now)); + m_Xdoc.AppendChild(Node); + + Node = m_Xdoc.CreateWhitespace("\r\n"); + m_Xdoc.AppendChild(Node); + + Node = m_Xdoc.CreateNode(XmlNodeType.Element, "LinkedControllers", ""); + m_Xdoc.AppendChild(Node); + + try { m_Xdoc.Save(m_linkedProfiles); } + catch (UnauthorizedAccessException) { Log.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } + + return saved; + } + + public bool LoadLinkedProfiles() + { + bool loaded = true; + if (File.Exists(m_linkedProfiles)) + { + XmlDocument linkedXdoc = new XmlDocument(); + XmlNode Node; + linkedXdoc.Load(m_linkedProfiles); + linkedProfiles.Clear(); + + try + { + Node = linkedXdoc.SelectSingleNode("/LinkedControllers"); + XmlNodeList links = Node.ChildNodes; + for (int i = 0, listLen = links.Count; i < listLen; i++) + { + XmlNode current = links[i]; + string serial = current.Name.Replace("MAC", string.Empty); + string profile = current.InnerText; + linkedProfiles[serial] = profile; + } + } + catch { loaded = false; } + } + else + { + Log.LogToGui("LinkedProfiles.xml can't be found.", false); + loaded = false; + } + + return loaded; + } + + public bool SaveLinkedProfiles() + { + bool saved = true; + if (File.Exists(m_linkedProfiles)) + { + XmlDocument linkedXdoc = new XmlDocument(); + XmlNode Node; + + Node = linkedXdoc.CreateXmlDeclaration("1.0", "utf-8", string.Empty); + linkedXdoc.AppendChild(Node); + + Node = linkedXdoc.CreateComment(string.Format(" Mac Address and Profile Linking Data. {0} ", DateTime.Now)); + linkedXdoc.AppendChild(Node); + + Node = linkedXdoc.CreateWhitespace("\r\n"); + linkedXdoc.AppendChild(Node); + + Node = linkedXdoc.CreateNode(XmlNodeType.Element, "LinkedControllers", ""); + linkedXdoc.AppendChild(Node); + + Dictionary.KeyCollection serials = linkedProfiles.Keys; + for (int i = 0, itemCount = linkedProfiles.Count; i < itemCount; i++) + { + string serial = serials.ElementAt(i); + string profile = linkedProfiles[serial]; + XmlElement link = linkedXdoc.CreateElement("MAC" + serial); + link.InnerText = profile; + Node.AppendChild(link); + } + + try { linkedXdoc.Save(m_linkedProfiles); } + catch (UnauthorizedAccessException) { Log.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } + } + else + { + saved = createLinkedProfiles(); + saved = saved && SaveLinkedProfiles(); + } + + return saved; + } + public void UpdateDS4CSetting(int deviceNum, string buttonName, bool shift, object action, string exts, DS4KeyType kt, int trigger = 0) { DS4Controls dc; @@ -3586,7 +3433,7 @@ namespace DS4Windows flushHIDQueue[device] = false; enableTouchToggle[device] = false; idleDisconnectTimeout[device] = 0; - touchpadJitterCompensation[device] = false; + touchpadJitterCompensation[device] = true; lowerRCOn[device] = false; ledAsBattery[device] = false; flashType[device] = 0; @@ -3640,7 +3487,8 @@ namespace DS4Windows startTouchpadOff[device] = false; useTPforControls[device] = false; useSAforMouse[device] = false; - sATriggers[device] = ""; + sATriggers[device] = string.Empty; + touchDisInvertTriggers[device] = new int[1] { -1 }; lsCurve[device] = rsCurve[device] = 0; gyroSensitivity[device] = 100; gyroSensVerticalScale[device] = 100; diff --git a/DS4Windows/DS4Forms/DS4Form.Designer.cs b/DS4Windows/DS4Forms/DS4Form.Designer.cs index a1deceb..ced6f1f 100644 --- a/DS4Windows/DS4Forms/DS4Form.Designer.cs +++ b/DS4Windows/DS4Forms/DS4Form.Designer.cs @@ -83,6 +83,11 @@ this.bnLight1 = new System.Windows.Forms.Button(); this.bnLight2 = new System.Windows.Forms.Button(); this.bnLight4 = new System.Windows.Forms.Button(); + this.lbLinkProfile = new System.Windows.Forms.Label(); + this.linkCB1 = new System.Windows.Forms.CheckBox(); + this.linkCB2 = new System.Windows.Forms.CheckBox(); + this.linkCB3 = new System.Windows.Forms.CheckBox(); + this.linkCB4 = new System.Windows.Forms.CheckBox(); this.lbNoControllers = new System.Windows.Forms.Label(); this.tabProfiles = new System.Windows.Forms.TabPage(); this.lBProfiles = new System.Windows.Forms.ListBox(); @@ -367,21 +372,21 @@ // tLPControllers // resources.ApplyResources(this.tLPControllers, "tLPControllers"); - this.tLPControllers.Controls.Add(this.bnLight3, 5, 3); + this.tLPControllers.Controls.Add(this.bnLight3, 6, 3); this.tLPControllers.Controls.Add(this.pBStatus1, 1, 1); this.tLPControllers.Controls.Add(this.lbPad1, 0, 1); this.tLPControllers.Controls.Add(this.lbPad2, 0, 2); - this.tLPControllers.Controls.Add(this.bnEditC3, 4, 3); - this.tLPControllers.Controls.Add(this.bnEditC4, 4, 4); + this.tLPControllers.Controls.Add(this.bnEditC3, 5, 3); + this.tLPControllers.Controls.Add(this.bnEditC4, 5, 4); this.tLPControllers.Controls.Add(this.lbPad3, 0, 3); this.tLPControllers.Controls.Add(this.lbPad4, 0, 4); - this.tLPControllers.Controls.Add(this.cBController1, 3, 1); - this.tLPControllers.Controls.Add(this.bnEditC2, 4, 2); - this.tLPControllers.Controls.Add(this.cBController2, 3, 2); - this.tLPControllers.Controls.Add(this.cBController3, 3, 3); - this.tLPControllers.Controls.Add(this.bnEditC1, 4, 1); - this.tLPControllers.Controls.Add(this.cBController4, 3, 4); - this.tLPControllers.Controls.Add(this.lbSelectedProfile, 3, 0); + this.tLPControllers.Controls.Add(this.cBController1, 4, 1); + this.tLPControllers.Controls.Add(this.bnEditC2, 5, 2); + this.tLPControllers.Controls.Add(this.cBController2, 4, 2); + this.tLPControllers.Controls.Add(this.cBController3, 4, 3); + this.tLPControllers.Controls.Add(this.bnEditC1, 5, 1); + this.tLPControllers.Controls.Add(this.cBController4, 4, 4); + this.tLPControllers.Controls.Add(this.lbSelectedProfile, 4, 0); this.tLPControllers.Controls.Add(this.lbID, 0, 0); this.tLPControllers.Controls.Add(this.lbStatus, 1, 0); this.tLPControllers.Controls.Add(this.lbBattery, 2, 0); @@ -392,9 +397,14 @@ this.tLPControllers.Controls.Add(this.pBStatus2, 1, 2); this.tLPControllers.Controls.Add(this.pBStatus3, 1, 3); this.tLPControllers.Controls.Add(this.pBStatus4, 1, 4); - this.tLPControllers.Controls.Add(this.bnLight1, 5, 1); - this.tLPControllers.Controls.Add(this.bnLight2, 5, 2); - this.tLPControllers.Controls.Add(this.bnLight4, 5, 4); + this.tLPControllers.Controls.Add(this.bnLight1, 6, 1); + this.tLPControllers.Controls.Add(this.bnLight2, 6, 2); + this.tLPControllers.Controls.Add(this.bnLight4, 6, 4); + this.tLPControllers.Controls.Add(this.lbLinkProfile, 3, 0); + this.tLPControllers.Controls.Add(this.linkCB1, 3, 1); + this.tLPControllers.Controls.Add(this.linkCB2, 3, 2); + this.tLPControllers.Controls.Add(this.linkCB3, 3, 3); + this.tLPControllers.Controls.Add(this.linkCB4, 3, 4); this.tLPControllers.Name = "tLPControllers"; // // bnLight3 @@ -613,6 +623,43 @@ this.bnLight4.UseVisualStyleBackColor = false; this.bnLight4.Click += new System.EventHandler(this.EditCustomLed); // + // lbLinkProfile + // + resources.ApplyResources(this.lbLinkProfile, "lbLinkProfile"); + this.lbLinkProfile.Name = "lbLinkProfile"; + // + // linkCB1 + // + resources.ApplyResources(this.linkCB1, "linkCB1"); + this.linkCB1.Name = "linkCB1"; + this.linkCB1.Tag = "0"; + this.linkCB1.UseVisualStyleBackColor = true; + this.linkCB1.CheckedChanged += new System.EventHandler(this.linkCB_CheckedChanged); + // + // linkCB2 + // + resources.ApplyResources(this.linkCB2, "linkCB2"); + this.linkCB2.Name = "linkCB2"; + this.linkCB2.Tag = "1"; + this.linkCB2.UseVisualStyleBackColor = true; + this.linkCB2.CheckedChanged += new System.EventHandler(this.linkCB_CheckedChanged); + // + // linkCB3 + // + resources.ApplyResources(this.linkCB3, "linkCB3"); + this.linkCB3.Name = "linkCB3"; + this.linkCB3.Tag = "2"; + this.linkCB3.UseVisualStyleBackColor = true; + this.linkCB3.CheckedChanged += new System.EventHandler(this.linkCB_CheckedChanged); + // + // linkCB4 + // + resources.ApplyResources(this.linkCB4, "linkCB4"); + this.linkCB4.Name = "linkCB4"; + this.linkCB4.Tag = "3"; + this.linkCB4.UseVisualStyleBackColor = true; + this.linkCB4.CheckedChanged += new System.EventHandler(this.linkCB_CheckedChanged); + // // lbNoControllers // resources.ApplyResources(this.lbNoControllers, "lbNoControllers"); @@ -1302,7 +1349,6 @@ private System.Windows.Forms.Label lbSelectedProfile; private System.Windows.Forms.Label lbID; private System.Windows.Forms.Label lbStatus; - private System.Windows.Forms.Label lbBattery; private System.Windows.Forms.Label lbBatt1; private System.Windows.Forms.Label lbBatt2; private System.Windows.Forms.Label lbBatt3; @@ -1383,6 +1429,12 @@ private System.Windows.Forms.RadioButton runStartProgRadio; private System.Windows.Forms.RadioButton runStartTaskRadio; private System.Windows.Forms.PictureBox uacPictureBox; + private System.Windows.Forms.Label lbBattery; + private System.Windows.Forms.Label lbLinkProfile; + private System.Windows.Forms.CheckBox linkCB1; + private System.Windows.Forms.CheckBox linkCB2; + private System.Windows.Forms.CheckBox linkCB3; + private System.Windows.Forms.CheckBox linkCB4; //private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; } } diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 3d5f323..954b9e7 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -14,57 +14,60 @@ using System.Text; using System.Globalization; using Microsoft.Win32.TaskScheduler; using System.Security.Principal; +using System.Threading; +using System.Drawing.Drawing2D; +using TaskRunner = System.Threading.Tasks.Task; +using NonFormTimer = System.Timers.Timer; using static DS4Windows.Global; namespace DS4Windows { public partial class DS4Form : Form { - public string[] arguements; + public string[] cmdArguments; delegate void LogDebugDelegate(DateTime Time, String Data, bool warning); delegate void NotificationDelegate(object sender, DebugEventArgs args); - delegate void BatteryStatusDelegate(object sender, BatteryReportArgs args); - delegate void ControllerRemovedDelegate(object sender, ControllerRemovedArgs args); delegate void DeviceStatusChangedDelegate(object sender, DeviceStatusChangeEventArgs args); delegate void DeviceSerialChangedDelegate(object sender, SerialChangeArgs args); - protected Label[] Pads, Batteries; - protected ComboBox[] cbs; - protected Button[] ebns; - protected Button[] lights; - protected PictureBox[] statPB; - protected ToolStripMenuItem[] shortcuts; + private Label[] Pads, Batteries; + private ComboBox[] cbs; + private Button[] ebns; + private Button[] lights; + private PictureBox[] statPB; + private ToolStripMenuItem[] shortcuts; + protected CheckBox[] linkedProfileCB; WebClient wc = new WebClient(); - Timer hotkeysTimer = new Timer(); - Timer autoProfilesTimer = new Timer(); + NonFormTimer hotkeysTimer = new NonFormTimer(); + NonFormTimer autoProfilesTimer = new NonFormTimer(); string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName; string appDataPpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows"; string oldappdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool"; - string tempProfileProgram = "null"; - float dpix, dpiy; + string tempProfileProgram = string.Empty; + double dpix, dpiy; List profilenames = new List(); List programpaths = new List(); List[] proprofiles; List turnOffTempProfiles; - private static int WM_QUERYENDSESSION = 0x11; - private static bool systemShutdown = false; + + private bool systemShutdown = false; private bool wasrunning = false; - delegate void ControllerStatusChangedDelegate(object sender, EventArgs e); - delegate void HotKeysDelegate(object sender, EventArgs e); Options opt; public Size oldsize; - WinProgs WP; public bool mAllowVisible; bool contextclose; string logFile = appdatapath + @"\DS4Service.log"; bool turnOffTemp; bool runningBat; + private bool changingService; + public bool ChangingService => changingService; Dictionary hoverTextDict = new Dictionary(); // 0 index is used for application version text. 1 - 4 indices are used for controller status - string[] notifyText = { "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion, + string[] notifyText = new string[5] + { "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion, string.Empty, string.Empty, string.Empty, string.Empty }; - internal const int BCM_FIRST = 0x1600; // Normal button - internal const int BCM_SETSHIELD = (BCM_FIRST + 0x000C); // Elevated button + internal const string UPDATER_VERSION = "1.1.404.0"; + internal static int WM_QUERYENDSESSION = 0x11; [DllImport("user32.dll")] private static extern IntPtr GetForegroundWindow(); @@ -72,36 +75,31 @@ namespace DS4Windows [DllImport("user32.dll")] private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); - [DllImport("user32.dll")] - private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, uint lParam); - [DllImport("kernel32.dll")] private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId); [DllImport("kernel32.dll")] private static extern bool CloseHandle(IntPtr handle); - [DllImport("psapi.dll")] - private static extern uint GetModuleBaseName(IntPtr hWnd, IntPtr hModule, StringBuilder lpFileName, int nSize); - [DllImport("psapi.dll")] private static extern uint GetModuleFileNameEx(IntPtr hWnd, IntPtr hModule, StringBuilder lpFileName, int nSize); public DS4Form(string[] args) { InitializeComponent(); + ThemeUtil.SetTheme(lvDebug); bnEditC1.Tag = 0; bnEditC2.Tag = 1; bnEditC3.Tag = 2; bnEditC4.Tag = 3; - this.StartWindowsCheckBox.CheckedChanged -= this.StartWindowsCheckBox_CheckedChanged; + StartWindowsCheckBox.CheckedChanged -= StartWindowsCheckBox_CheckedChanged; saveProfiles.Filter = Properties.Resources.XMLFiles + "|*.xml"; openProfiles.Filter = Properties.Resources.XMLFiles + "|*.xml"; - arguements = args; - ThemeUtil.SetTheme(lvDebug); + cmdArguments = args; + Pads = new Label[4] { lbPad1, lbPad2, lbPad3, lbPad4 }; Batteries = new Label[4] { lbBatt1, lbBatt2, lbBatt3, lbBatt4 }; cbs = new ComboBox[4] { cBController1, cBController2, cBController3, cBController4 }; @@ -113,6 +111,8 @@ namespace DS4Windows (ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[2], (ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[3] }; + linkedProfileCB = new CheckBox[4] { linkCB1, linkCB2, linkCB3, linkCB4 }; + SystemEvents.PowerModeChanged += OnPowerChange; tSOptions.Visible = false; bool firstrun = false; @@ -151,14 +151,7 @@ namespace DS4Windows new SaveWhere(false).ShowDialog(); } - if (firstrun) - CheckDrivers(); - else - { - var AppCollectionThread = new System.Threading.Thread(() => CheckDrivers()); - AppCollectionThread.IsBackground = true; - AppCollectionThread.Start(); - } + TaskRunner.Run(() => CheckDrivers()); if (string.IsNullOrEmpty(appdatapath)) { @@ -166,7 +159,7 @@ namespace DS4Windows return; } - Graphics g = this.CreateGraphics(); + Graphics g = CreateGraphics(); try { dpix = g.DpiX / 100f * 1.041666666667f; @@ -218,7 +211,6 @@ namespace DS4Windows } } - //MessageBox.Show(Environment.OSVersion.VersionString); cBUseWhiteIcon.Checked = UseWhiteIcon; Icon = Properties.Resources.DS4W; notifyIcon1.Icon = UseWhiteIcon ? Properties.Resources.DS4W___White : Properties.Resources.DS4W; @@ -293,12 +285,13 @@ namespace DS4Windows bool start = true; bool mini = false; - for (int i = 0, argslen = arguements.Length; i < argslen; i++) + for (int i = 0, argslen = cmdArguments.Length; i < argslen; i++) { - if (arguements[i] == "-stop") + if (cmdArguments[i] == "-stop") start = false; - if (arguements[i] == "-m") + else if (cmdArguments[i] == "-m") mini = true; + if (mini && start) break; } @@ -318,19 +311,11 @@ namespace DS4Windows opt.FormBorderStyle = FormBorderStyle.None; tabProfiles.Controls.Add(opt); - for (int i = 0; i < 4; i++) - { - LoadProfile(i, false, Program.rootHub, false); - if (UseCustomLed[i]) - lights[i].BackColor = CustomColor[i].ToColorA; - else - lights[i].BackColor = MainColor[i].ToColorA; - } - - autoProfilesTimer.Tick += CheckAutoProfiles; + autoProfilesTimer.Elapsed += CheckAutoProfiles; autoProfilesTimer.Interval = 1000; LoadP(); + LoadLinkedProfiles(); Global.BatteryStatusChange += BatteryStatusUpdate; Global.ControllerRemoved += ControllerRemovedChange; @@ -343,7 +328,7 @@ namespace DS4Windows Enable_Controls(3, false); btnStartStop.Text = Properties.Resources.StartText; - hotkeysTimer.Tick += Hotkeys; + hotkeysTimer.Elapsed += Hotkeys; if (SwipeProfiles) { hotkeysTimer.Start(); @@ -353,10 +338,6 @@ namespace DS4Windows btnStartStop_Clicked(); startToolStripMenuItem.Text = btnStartStop.Text; - //if (!tLPControllers.Visible) - // tabMain.SelectedIndex = 1; - - //cBNotifications.Checked = Notifications; cBoxNotifications.SelectedIndex = Notifications; cBSwipeProfiles.Checked = SwipeProfiles; int checkwhen = CheckWhen; @@ -383,14 +364,14 @@ namespace DS4Windows if (File.Exists(exepath + "\\Updater.exe")) { - System.Threading.Thread.Sleep(2000); + Thread.Sleep(2000); File.Delete(exepath + "\\Updater.exe"); } if (!Directory.Exists(appdatapath + "\\Virtual Bus Driver")) linkUninstall.Visible = false; - bool isElevated = Global.IsAdministrator(); + bool isElevated = IsAdministrator(); if (!isElevated) { Image tempImg = new Bitmap(uacPictureBox.Width, uacPictureBox.Height); @@ -429,9 +410,9 @@ namespace DS4Windows } } - UpdateTheUpdater(); + TaskRunner.Run(() => { UpdateTheUpdater(); }); - this.StartWindowsCheckBox.CheckedChanged += new EventHandler(this.StartWindowsCheckBox_CheckedChanged); + StartWindowsCheckBox.CheckedChanged += new EventHandler(StartWindowsCheckBox_CheckedChanged); new ToolTip().SetToolTip(StartWindowsCheckBox, Properties.Resources.RunAtStartup); populateHoverTextDict(); @@ -463,31 +444,26 @@ namespace DS4Windows hoverTextDict[StartWindowsCheckBox] = Properties.Resources.RunAtStartup; } - private Image AddUACShieldToImage(Image image) + private void AddUACShieldToImage(Image image) { Bitmap shield = SystemIcons.Shield.ToBitmap(); shield.MakeTransparent(); Graphics g = Graphics.FromImage(image); - g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; + g.CompositingMode = CompositingMode.SourceOver; double aspectRatio = shield.Width / (double)shield.Height; int finalWidth = Convert.ToInt32(image.Height * aspectRatio); int finalHeight = Convert.ToInt32(image.Width / aspectRatio); g.DrawImage(shield, new Rectangle(0, 0, finalWidth, finalHeight)); - - return image; } private void blankControllerTab() { - bool nocontrollers = true; - for (Int32 Index = 0, PadsLen = Pads.Length; Index < PadsLen; Index++) + for (int Index = 0, PadsLen = Pads.Length; + Index < PadsLen; Index++) { - // Make sure a controller exists if (Index < ControlService.DS4_CONTROLLER_COUNT) { - Pads[Index].Text = ""; - statPB[Index].Visible = false; toolTip1.SetToolTip(statPB[Index], ""); Batteries[Index].Text = Properties.Resources.NA; Pads[Index].Text = Properties.Resources.Disconnected; @@ -495,18 +471,18 @@ namespace DS4Windows } } - lbNoControllers.Visible = nocontrollers; - tLPControllers.Visible = !nocontrollers; + lbNoControllers.Visible = true; + tLPControllers.Visible = false; } - private async void UpdateTheUpdater() + private void UpdateTheUpdater() { if (File.Exists(exepath + "\\Update Files\\DS4Updater.exe")) { Process[] processes = Process.GetProcessesByName("DS4Updater"); while (processes.Length > 0) { - await System.Threading.Tasks.Task.Delay(500); + Thread.Sleep(500); } File.Delete(exepath + "\\DS4Updater.exe"); @@ -520,18 +496,12 @@ namespace DS4Windows if (!mAllowVisible) { value = false; - if (!this.IsHandleCreated) CreateHandle(); + if (!IsHandleCreated) CreateHandle(); } base.SetVisibleCore(value); } - private void showToolStripMenuItem_Click(object sender, EventArgs e) - { - mAllowVisible = true; - Show(); - } - public static string GetTopWindowName() { IntPtr hWnd = GetForegroundWindow(); @@ -615,7 +585,7 @@ namespace DS4Windows private void CheckAutoProfiles(object sender, EventArgs e) { //Check for process for auto profiles - if (tempProfileProgram == "null") + if (string.IsNullOrEmpty(tempProfileProgram)) { string windowName = GetTopWindowName().ToLower().Replace('/', '\\'); for (int i = 0, pathsLen = programpaths.Count; i < pathsLen; i++) @@ -654,7 +624,7 @@ namespace DS4Windows string windowName = GetTopWindowName().ToLower().Replace('/', '\\'); if (tempProfileProgram != windowName) { - tempProfileProgram = "null"; + tempProfileProgram = string.Empty; for (int j = 0; j < 4; j++) LoadProfile(j, false, Program.rootHub); @@ -764,7 +734,7 @@ namespace DS4Windows FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); string version = fvi.FileVersion; string newversion = File.ReadAllText(appdatapath + "\\version.txt").Trim(); - if (version.Replace(',', '.').CompareTo(newversion) == -1)//CompareVersions(); + if (version.Replace(',', '.').CompareTo(newversion) == -1) { if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion), Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) @@ -876,7 +846,7 @@ namespace DS4Windows public void RefreshAutoProfilesPage() { tabAutoProfiles.Controls.Clear(); - WP = new WinProgs(profilenames.ToArray(), this); + WinProgs WP = new WinProgs(profilenames.ToArray(), this); WP.TopLevel = false; WP.FormBorderStyle = FormBorderStyle.None; WP.Visible = true; @@ -944,19 +914,19 @@ namespace DS4Windows protected void Form_Resize(object sender, EventArgs e) { - if (FormWindowState.Minimized == this.WindowState) + if (FormWindowState.Minimized == WindowState) { - this.Hide(); - this.ShowInTaskbar = false; - this.FormBorderStyle = FormBorderStyle.None; + Hide(); + ShowInTaskbar = false; + FormBorderStyle = FormBorderStyle.None; } - else if (FormWindowState.Normal == this.WindowState) + else if (FormWindowState.Normal == WindowState) { //mAllowVisible = true; - this.Show(); - this.ShowInTaskbar = true; - this.FormBorderStyle = FormBorderStyle.Sizable; + Show(); + ShowInTaskbar = true; + FormBorderStyle = FormBorderStyle.Sizable; } chData.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); @@ -967,35 +937,65 @@ namespace DS4Windows btnStartStop_Clicked(); } + private void serviceStartup(bool log) + { + var uiContext = SynchronizationContext.Current; + changingService = true; + TaskRunner.Run(() => + { + //Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; + Program.rootHub.Start(uiContext, log); + Invoke((System.Action)(() => { serviceStartupFinish(); })); + changingService = false; + }); + } + + private void serviceStartupFinish() + { + if (SwipeProfiles && !hotkeysTimer.Enabled) + { + hotkeysTimer.Start(); + } + + if (programpaths.Count > 0 && !autoProfilesTimer.Enabled) + { + autoProfilesTimer.Start(); + } + + startToolStripMenuItem.Text = btnStartStop.Text = Properties.Resources.StopText; + } + + private void serviceShutdown(bool log) + { + changingService = true; + TaskRunner.Run(() => + { + Program.rootHub.Stop(log); + Invoke((System.Action)(() => { serviceShutdownFinish(); })); + changingService = false; + }); + } + + private void serviceShutdownFinish() + { + hotkeysTimer.Stop(); + autoProfilesTimer.Stop(); + startToolStripMenuItem.Text = btnStartStop.Text = Properties.Resources.StartText; + blankControllerTab(); + populateFullNotifyText(); + } + public void btnStartStop_Clicked(bool log = true) { if (btnStartStop.Text == Properties.Resources.StartText) { - Program.rootHub.Start(log); - if (SwipeProfiles && !hotkeysTimer.Enabled) - { - hotkeysTimer.Start(); - } - - if (programpaths.Count > 0 && !autoProfilesTimer.Enabled) - { - autoProfilesTimer.Start(); - } - - btnStartStop.Text = Properties.Resources.StopText; + serviceStartup(log); } else if (btnStartStop.Text == Properties.Resources.StopText) { blankControllerTab(); - Program.rootHub.Stop(log); - hotkeysTimer.Stop(); - autoProfilesTimer.Stop(); - btnStartStop.Text = Properties.Resources.StartText; - blankControllerTab(); - populateFullNotifyText(); + serviceShutdown(log); } - - startToolStripMenuItem.Text = btnStartStop.Text; } protected void btnClear_Click(object sender, EventArgs e) @@ -1021,9 +1021,11 @@ namespace DS4Windows hotplugCounter++; } + var uiContext = SynchronizationContext.Current; if (!inHotPlug) { - InnerHotplug2(); + inHotPlug = true; + TaskRunner.Run(() => { Thread.Sleep(100); InnerHotplug2(uiContext); }); } } } @@ -1038,76 +1040,53 @@ namespace DS4Windows catch { } } - protected async void InnerHotplug2() + private void InnerHotplug2(SynchronizationContext uiContext) { - //await System.Threading.Tasks.Task.Delay(50); + inHotPlug = true; - /*if (inHotPlug) + bool loopHotplug = false; + lock (hotplugCounterLock) { - await System.Threading.Tasks.Task.Run(() => { while (inHotPlug) { System.Threading.Thread.Sleep(50); } }); + loopHotplug = hotplugCounter > 0; } - */ - //lock (this) + while (loopHotplug == true) { - inHotPlug = true; - System.Threading.SynchronizationContext uiContext = System.Threading.SynchronizationContext.Current; - int tempCount = 0; + Program.rootHub.HotPlug(uiContext); + //TaskRunner.Run(() => { Program.rootHub.HotPlug(uiContext); }); lock (hotplugCounterLock) { - tempCount = hotplugCounter; + hotplugCounter--; + loopHotplug = hotplugCounter > 0; } - - while (tempCount > 0) - { - await System.Threading.Tasks.Task.Run(() => { Program.rootHub.HotPlug(uiContext); }); - lock (hotplugCounterLock) - { - hotplugCounter--; - tempCount = hotplugCounter; - } - } - - //Program.rootHub.HotPlug(); - inHotPlug = false; } + + inHotPlug = false; } protected void BatteryStatusUpdate(object sender, BatteryReportArgs args) { - if (this.InvokeRequired) + string battery; + int level = args.getLevel(); + bool charging = args.isCharging(); + int Index = args.getIndex(); + if (charging) { - try - { - BatteryStatusDelegate d = new BatteryStatusDelegate(BatteryStatusUpdate); - this.BeginInvoke(d, new object[] { sender, args }); - } - catch { } + if (level >= 100) + battery = Properties.Resources.Full; + else + battery = level + "%+"; } else { - string battery; - int level = args.getLevel(); - bool charging = args.isCharging(); - int Index = args.getIndex(); - if (charging) - { - if (level >= 100) - battery = Properties.Resources.Full; - else - battery = level + "%+"; - } - else - { - battery = level + "%"; - } - - Batteries[args.getIndex()].Text = battery; - - // Update device battery level display for tray icon - generateDeviceNotifyText(args.getIndex()); - populateNotifyText(); + battery = level + "%"; } + + Batteries[args.getIndex()].Text = battery; + + // Update device battery level display for tray icon + generateDeviceNotifyText(args.getIndex()); + populateNotifyText(); } protected void populateFullNotifyText() @@ -1184,9 +1163,35 @@ namespace DS4Windows { int devIndex = args.getIndex(); string serial = args.getSerial(); - if (devIndex >= 0 && devIndex < ControlService.DS4_CONTROLLER_COUNT) + DS4Device device = (devIndex >= 0 && devIndex < ControlService.DS4_CONTROLLER_COUNT) ? + Program.rootHub.DS4Controllers[devIndex] : null; + if (device != null) { Pads[devIndex].Text = serial; + if (device.isSynced()) + { + linkedProfileCB[devIndex].Enabled = true; + } + else + { + linkedProfileCB[devIndex].Enabled = false; + } + + if (device.isValidSerial() && containsLinkedProfile(device.getMacAddress())) + { + ProfilePath[devIndex] = getLinkedProfile(device.getMacAddress()); + int profileIndex = cbs[devIndex].FindString(ProfilePath[devIndex]); + if (profileIndex >= 0) + { + cbs[devIndex].SelectedIndex = profileIndex; + } + } + else + { + ProfilePath[devIndex] = OlderProfilePath[devIndex]; + } + + linkedProfileCB[devIndex].Checked = false; } } } @@ -1216,6 +1221,20 @@ namespace DS4Windows { Pads[Index].Text = Program.rootHub.getDS4MacAddress(Index); + linkedProfileCB[Index].CheckedChanged -= linkCB_CheckedChanged; + if (DS4Device.isValidSerial(Pads[Index].Text)) + { + linkedProfileCB[Index].Checked = containsLinkedProfile(Pads[Index].Text); + linkedProfileCB[Index].Enabled = true; + } + else + { + linkedProfileCB[Index].Checked = false; + linkedProfileCB[Index].Enabled = false; + } + + linkedProfileCB[Index].CheckedChanged += linkCB_CheckedChanged; + switch (Program.rootHub.getDS4Status(Index)) { case "USB": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.USB; toolTip1.SetToolTip(statPB[Index], ""); break; @@ -1225,6 +1244,19 @@ namespace DS4Windows } Batteries[Index].Text = Program.rootHub.getDS4Battery(Index); + int profileIndex = cbs[Index].FindString(ProfilePath[Index]); + if (profileIndex >= 0) + { + cbs[Index].SelectedValueChanged -= Profile_Changed; + cbs[Index].SelectedIndex = profileIndex; + cbs[Index].SelectedValueChanged += Profile_Changed; + } + + if (UseCustomLed[Index]) + lights[Index].BackColor = CustomColor[Index].ToColorA; + else + lights[Index].BackColor = MainColor[Index].ToColorA; + if (Pads[Index].Text != String.Empty) { if (runningBat) @@ -1263,113 +1295,31 @@ namespace DS4Windows protected void ControllerRemovedChange(object sender, ControllerRemovedArgs args) { - if (this.InvokeRequired) - { - try - { - ControllerRemovedDelegate d = new ControllerRemovedDelegate(ControllerRemovedChange); - this.BeginInvoke(d, new object[] { sender, args }); - } - catch { } - } - else - { - int devIndex = args.getIndex(); - Pads[devIndex].Text = Properties.Resources.Disconnected; - Enable_Controls(devIndex, false); - statPB[devIndex].Visible = false; - toolTip1.SetToolTip(statPB[devIndex], ""); + int devIndex = args.getIndex(); + Pads[devIndex].Text = Properties.Resources.Disconnected; + Enable_Controls(devIndex, false); + statPB[devIndex].Visible = false; + toolTip1.SetToolTip(statPB[devIndex], ""); - DS4Device[] devices = Program.rootHub.DS4Controllers; - int controllerLen = devices.Length; - bool nocontrollers = true; - for (Int32 i = 0, PadsLen = Pads.Length; nocontrollers && i < PadsLen; i++) - { - DS4Device d = devices[i]; - if (d != null) - { - nocontrollers = false; - } - } - - lbNoControllers.Visible = nocontrollers; - tLPControllers.Visible = !nocontrollers; - - // Update device battery level display for tray icon - generateDeviceNotifyText(devIndex); - populateNotifyText(); - } - } - - /* TODO: Possible remove method */ - /*protected void ControllerStatusChange(object sender, EventArgs e) - { - if (InvokeRequired) - Invoke(new ControllerStatusChangedDelegate(ControllerStatusChange), new object[] { sender, e }); - else - ControllerStatusChanged(); - } - */ - - /* TODO: Possible remove method */ - /*protected void ControllerStatusChanged() - { - String tooltip = "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; - bool nocontrollers = true; DS4Device[] devices = Program.rootHub.DS4Controllers; int controllerLen = devices.Length; - for (Int32 Index = 0, PadsLen = Pads.Length; Index < PadsLen; Index++) + bool nocontrollers = true; + for (Int32 i = 0, PadsLen = Pads.Length; nocontrollers && i < PadsLen; i++) { - // Make sure a controller exists - if (Index < controllerLen) + DS4Device d = devices[i]; + if (d != null) { - Pads[Index].Text = Program.rootHub.getDS4MacAddress(Index); - DS4Device d = devices[Index]; - - switch (Program.rootHub.getDS4Status(Index)) - { - case "USB": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.USB; toolTip1.SetToolTip(statPB[Index], ""); break; - case "BT": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.BT; toolTip1.SetToolTip(statPB[Index], "Right click to disconnect"); break; - case "SONYWA": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.BT; toolTip1.SetToolTip(statPB[Index], "Right click to disconnect"); break; - default: statPB[Index].Visible = false; toolTip1.SetToolTip(statPB[Index], ""); break; - } - - Batteries[Index].Text = Program.rootHub.getDS4Battery(Index); - if (Pads[Index].Text != String.Empty) - { - if (runningBat) - { - SendKeys.Send("A"); - runningBat = false; - } - - Pads[Index].Enabled = true; - nocontrollers = false; - if (Pads[Index].Text != Properties.Resources.Connecting) - { - Enable_Controls(Index, true); - } - } - else - { - Pads[Index].Text = Properties.Resources.Disconnected; - Enable_Controls(Index, false); - } - //if (((Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index)).Length > 50) - //MessageBox.Show(((Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index)).Length.ToString()); - if (Program.rootHub.getShortDS4ControllerInfo(Index) != Properties.Resources.NoneText) - tooltip += "\n" + (Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index); // Carefully stay under the 63 character limit. + nocontrollers = false; } } lbNoControllers.Visible = nocontrollers; tLPControllers.Visible = !nocontrollers; - if (tooltip.Length > 63) - notifyIcon1.Text = tooltip.Substring(0, 63); - else - notifyIcon1.Text = tooltip; + + // Update device battery level display for tray icon + generateDeviceNotifyText(devIndex); + populateNotifyText(); } - */ private void pBStatus_MouseClick(object sender, MouseEventArgs e) { @@ -1397,18 +1347,9 @@ namespace DS4Windows cbs[device].Visible = on; shortcuts[device].Visible = on; Batteries[device].Visible = on; + linkedProfileCB[device].Visible = on; } - /* TODO: Remove method in future */ - /*void ScpForm_Report(object sender, EventArgs e) - { - if (InvokeRequired) - Invoke(new HotKeysDelegate(Hotkeys), new object[] { sender, e }); - else - Hotkeys(sender, e); - } - */ - protected void On_Debug(object sender, DebugEventArgs e) { LogDebug(e.Time, e.Data, e.Warning); @@ -1539,7 +1480,9 @@ namespace DS4Windows private void ShowOptions(int devID, string profile) { Show(); - tabMain.SelectedIndex = 1; + + lBProfiles.Visible = false; + WindowState = FormWindowState.Normal; toolStrip1.Enabled = false; tSOptions.Visible = true; @@ -1565,11 +1508,16 @@ namespace DS4Windows opt.Reload(devID, profile); opt.inputtimer.Start(); opt.Visible = true; + tabMain.SelectedIndex = 1; } public void OptionsClosed() { RefreshProfiles(); + + if (!lbNoControllers.Visible) + tabMain.SelectedIndex = 0; + Size = oldsize; oldsize = new Size(0, 0); tSBKeepSize.Text = Properties.Resources.KeepThisSize; @@ -1585,11 +1533,10 @@ namespace DS4Windows lbLastMessage.Text = lvDebug.Items[lvDebugItemCount - 1].SubItems[1].Text; } - if (!lbNoControllers.Visible) - tabMain.SelectedIndex = 0; - opt.inputtimer.Stop(); opt.sixaxisTimer.Stop(); + + lBProfiles.Visible = true; } private void editButtons_Click(object sender, EventArgs e) @@ -1607,7 +1554,7 @@ namespace DS4Windows private void editMenu_Click(object sender, EventArgs e) { mAllowVisible = true; - this.Show(); + Show(); WindowState = FormWindowState.Normal; ToolStripMenuItem em = (ToolStripMenuItem)sender; int i = Convert.ToInt32(em.Tag); @@ -1646,9 +1593,33 @@ namespace DS4Windows if (Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build < 10586) btnConnectDS4Win10.Visible = exclusiveMode; - btnStartStop_Clicked(false); - btnStartStop_Clicked(false); + hideDS4CheckBox.Enabled = false; Save(); + btnStartStop_Clicked(false); + finishHideDS4Check(); + } + + private async void finishHideDS4Check() + { + await TaskRunner.Factory.StartNew(() => + { + while (changingService) + { + Thread.Sleep(10); + } + }); + + btnStartStop_Clicked(false); + + await TaskRunner.Factory.StartNew(() => + { + while (changingService) + { + Thread.Sleep(10); + } + }); + + hideDS4CheckBox.Enabled = true; } private void startMinimizedCheckBox_CheckedChanged(object sender, EventArgs e) @@ -1670,9 +1641,12 @@ namespace DS4Windows { if (cb.SelectedIndex < cb.Items.Count - 1) { - for (int i = 0; i < shortcuts[tdevice].DropDownItems.Count; i++) + for (int i = 0, arlen = shortcuts[tdevice].DropDownItems.Count; i < arlen; i++) + { if (!(shortcuts[tdevice].DropDownItems[i] is ToolStripSeparator)) ((ToolStripMenuItem)shortcuts[tdevice].DropDownItems[i]).Checked = false; + } + ((ToolStripMenuItem)shortcuts[tdevice].DropDownItems[cb.SelectedIndex]).Checked = true; LogDebug(DateTime.Now, Properties.Resources.UsingProfile.Replace("*number*", (tdevice + 1).ToString()).Replace("*Profile name*", cb.Text), false); shortcuts[tdevice].Text = Properties.Resources.ContextEdit.Replace("*number*", (tdevice + 1).ToString()); @@ -1683,9 +1657,24 @@ namespace DS4Windows lights[tdevice].BackColor = CustomColor[tdevice].ToColorA; else lights[tdevice].BackColor = MainColor[tdevice].ToColorA; + + if (linkedProfileCB[tdevice].Checked) + { + DS4Device device = Program.rootHub.DS4Controllers[tdevice]; + if (device != null && device.isValidSerial()) + { + changeLinkedProfile(device.getMacAddress(), ProfilePath[tdevice]); + SaveLinkedProfiles(); + } + } + else + { + OlderProfilePath[tdevice] = ProfilePath[tdevice]; + } } else if (cb.SelectedIndex == cb.Items.Count - 1 && cb.Items.Count > 1) //if +New Profile selected ShowOptions(tdevice, ""); + if (cb.Text == "(" + Properties.Resources.NoProfileLoaded + ")") ebns[tdevice].Text = Properties.Resources.New; else @@ -1711,13 +1700,13 @@ namespace DS4Windows private void exitToolStripMenuItem_Click(object sender, EventArgs e) { contextclose = true; - this.Close(); + Close(); } private void openToolStripMenuItem_Click(object sender, EventArgs e) { mAllowVisible = true; - this.Show(); + Show(); Focus(); WindowState = FormWindowState.Normal; } @@ -1732,13 +1721,13 @@ namespace DS4Windows if (e.Button == MouseButtons.Middle) { contextclose = true; - this.Close(); + Close(); } } private void notifyIcon1_BalloonTipClicked(object sender, EventArgs e) { - this.Show(); + Show(); WindowState = FormWindowState.Normal; } @@ -2058,22 +2047,22 @@ namespace DS4Windows FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); string version2 = fvi.FileVersion; string newversion2 = File.ReadAllText(appdatapath + "\\version.txt").Trim(); - if (version2.Replace(',', '.').CompareTo(newversion2) == -1)//CompareVersions(); + if (version2.Replace(',', '.').CompareTo(newversion2) == -1) { if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion2), Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (!File.Exists(exepath + "\\DS4Updater.exe") || (File.Exists(exepath + "\\DS4Updater.exe") - && (FileVersionInfo.GetVersionInfo(exepath + "\\DS4Updater.exe").FileVersion.CompareTo("1.1.0.0") == -1))) + && (FileVersionInfo.GetVersionInfo(exepath + "\\DS4Updater.exe").FileVersion.CompareTo(UPDATER_VERSION) == -1))) { - Uri url2 = new Uri("http://ds4windows.com/Files/DS4Updater.exe"); + Uri url2 = new Uri("http://23.239.26.40/ds4windows/files/DS4Updater.exe"); WebClient wc2 = new WebClient(); if (appdatapath == exepath) wc2.DownloadFile(url2, exepath + "\\DS4Updater.exe"); else { MessageBox.Show(Properties.Resources.PleaseDownloadUpdater); - Process.Start("http://ds4windows.com/Files/DS4Updater.exe"); + Process.Start("http://23.239.26.40/ds4windows/files/DS4Updater.exe"); } } @@ -2167,7 +2156,7 @@ namespace DS4Windows } else if (userClosing && closeMini && !contextclose) { - this.WindowState = FormWindowState.Minimized; + WindowState = FormWindowState.Minimized; e.Cancel = true; return; } @@ -2275,7 +2264,7 @@ namespace DS4Windows Label lb = (Label)sender; int i = Convert.ToInt32(lb.Tag); DS4Device d = Program.rootHub.DS4Controllers[i]; - if (d != null && d.ConnectionType == ConnectionType.BT) + if (d != null) { double latency = d.Latency; toolTip1.Hide(Pads[i]); @@ -2437,6 +2426,37 @@ namespace DS4Windows DownloadLang = cBDownloadLangauge.Checked; } + private void linkCB_CheckedChanged(object sender, EventArgs e) + { + CheckBox linkCb = (CheckBox)sender; + int i = Convert.ToInt32(linkCb.Tag); + bool check = linkCb.Checked; + Global.linkedProfileCheck[i] = check; + DS4Device device = Program.rootHub.DS4Controllers[i]; + if (device != null && device.isSynced()) + { + if (check) + { + if (device.isValidSerial()) + { + changeLinkedProfile(device.getMacAddress(), ProfilePath[i]); + } + } + else + { + removeLinkedProfile(device.getMacAddress()); + ProfilePath[i] = OlderProfilePath[i]; + int profileIndex = cbs[i].FindString(ProfilePath[i]); + if (profileIndex >= 0) + { + cbs[i].SelectedIndex = profileIndex; + } + } + + SaveLinkedProfiles(); + } + } + private void cBFlashWhenLate_CheckedChanged(object sender, EventArgs e) { FlashWhenLate = cBFlashWhenLate.Checked; diff --git a/DS4Windows/DS4Forms/DS4Form.es.resx b/DS4Windows/DS4Forms/DS4Form.es.resx index bd0ae3d..79b6a44 100644 --- a/DS4Windows/DS4Forms/DS4Form.es.resx +++ b/DS4Windows/DS4Forms/DS4Form.es.resx @@ -149,25 +149,25 @@ 280, 24 - Editar perfil del Controlador 1 + Editar perfil del Control 1 280, 24 - Editar perfil del Controlador 2 + Editar perfil del Control 2 280, 24 - Editar perfil del Controlador 3 + Editar perfil del Control 3 280, 24 - Editar perfil del Controlador 4 + Editar perfil del Control 4 277, 6 @@ -302,10 +302,10 @@ 34, 28 - Ningún controlador conectado (Máx 4) + Ningún control conectado (Máx 4) - Controladores + Control 240, 24 @@ -317,25 +317,25 @@ 240, 24 - Asignar al Controlador 1 + Asignar al Control 1 240, 24 - Asignar al Controlador 2 + Asignar al Control 2 240, 24 - Asignar al Controlador 3 + Asignar al Control 3 240, 24 - Asignar al Controlador 4 + Asignar al Control 4 240, 24 @@ -464,13 +464,13 @@ 185, 21 - Ocultar Controlador DS4 + Ocultar Control DS4 305, 21 - Deslizar el panel táctil para cambiar de perfil + Deslice el panel táctil para cambiar de perfil 198, 21 @@ -599,7 +599,7 @@ 235, 17 - Controlador/Configuración de Driver + Control/Configuración de Driver 261, 17 diff --git a/DS4Windows/DS4Forms/DS4Form.resx b/DS4Windows/DS4Forms/DS4Form.resx index 2b2d924..c8b5a46 100644 --- a/DS4Windows/DS4Forms/DS4Form.resx +++ b/DS4Windows/DS4Forms/DS4Form.resx @@ -430,7 +430,7 @@ NoControl - 0, 127 + 0, 142 896, 23 @@ -457,7 +457,7 @@ True - 6 + 7 Fill @@ -469,10 +469,10 @@ NoControl - 813, 74 + 794, 89 - 80, 22 + 99, 22 50 @@ -496,7 +496,7 @@ NoControl - 386, 19 + 363, 34 39, 20 @@ -532,7 +532,7 @@ NoControl - 3, 21 + 3, 36 111, 15 @@ -568,7 +568,7 @@ NoControl - 3, 49 + 3, 64 70, 15 @@ -598,10 +598,10 @@ NoControl - 770, 74 + 754, 89 - 37, 22 + 34, 22 43 @@ -628,10 +628,10 @@ NoControl - 770, 102 + 754, 117 - 37, 22 + 34, 22 43 @@ -664,7 +664,7 @@ NoControl - 3, 77 + 3, 92 70, 15 @@ -700,7 +700,7 @@ NoControl - 3, 105 + 3, 120 70, 15 @@ -727,7 +727,7 @@ None - 653, 18 + 637, 33 111, 21 @@ -754,10 +754,10 @@ NoControl - 770, 46 + 754, 61 - 37, 22 + 34, 22 43 @@ -781,7 +781,7 @@ None - 653, 46 + 637, 61 111, 21 @@ -805,7 +805,7 @@ None - 653, 74 + 637, 89 111, 21 @@ -832,10 +832,10 @@ NoControl - 770, 18 + 754, 33 - 37, 22 + 34, 22 43 @@ -859,7 +859,7 @@ None - 653, 102 + 637, 117 111, 21 @@ -892,7 +892,7 @@ NoControl - 654, 0 + 638, 7 109, 15 @@ -928,7 +928,7 @@ NoControl - 3, 0 + 3, 7 21, 15 @@ -964,7 +964,7 @@ NoControl - 382, 0 + 359, 7 47, 15 @@ -1000,7 +1000,7 @@ NoControl - 546, 0 + 472, 7 51, 15 @@ -1036,7 +1036,7 @@ NoControl - 552, 21 + 478, 36 39, 15 @@ -1072,7 +1072,7 @@ NoControl - 552, 49 + 478, 64 39, 15 @@ -1108,7 +1108,7 @@ NoControl - 552, 77 + 478, 92 39, 15 @@ -1144,7 +1144,7 @@ NoControl - 552, 105 + 478, 120 39, 15 @@ -1174,7 +1174,7 @@ NoControl - 386, 47 + 363, 62 39, 20 @@ -1204,7 +1204,7 @@ NoControl - 386, 75 + 363, 90 39, 20 @@ -1234,7 +1234,7 @@ NoControl - 386, 103 + 363, 118 39, 20 @@ -1267,10 +1267,10 @@ NoControl - 813, 18 + 794, 33 - 80, 22 + 99, 22 50 @@ -1297,10 +1297,10 @@ NoControl - 813, 46 + 794, 61 - 80, 22 + 99, 22 51 @@ -1327,10 +1327,10 @@ NoControl - 813, 102 + 794, 117 - 80, 22 + 99, 22 52 @@ -1347,6 +1347,177 @@ 27 + + None + + + True + + + Microsoft Sans Serif, 9pt, style=Bold + + + NoControl + + + 560, 0 + + + 67, 30 + + + 53 + + + Link Profile/ID + + + MiddleCenter + + + lbLinkProfile + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tLPControllers + + + 28 + + + None + + + True + + + None + + + NoControl + + + 586, 37 + + + 15, 14 + + + 54 + + + linkCB1 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tLPControllers + + + 29 + + + None + + + True + + + None + + + NoControl + + + 586, 65 + + + 15, 14 + + + 55 + + + linkCB2 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tLPControllers + + + 30 + + + None + + + True + + + None + + + NoControl + + + 586, 93 + + + 15, 14 + + + 56 + + + linkCB3 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tLPControllers + + + 31 + + + None + + + True + + + None + + + NoControl + + + 586, 121 + + + 15, 14 + + + 57 + + + linkCB4 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tLPControllers + + + 32 + Top @@ -1357,7 +1528,7 @@ 5 - 896, 127 + 896, 142 46 @@ -1375,7 +1546,7 @@ 1 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="bnLight3" Row="3" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="pBStatus1" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbPad1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPad2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="bnEditC3" Row="3" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="bnEditC4" Row="4" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="lbPad3" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPad4" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="cBController1" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="bnEditC2" Row="2" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="cBController2" Row="2" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="cBController3" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="bnEditC1" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="cBController4" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="lbSelectedProfile" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="lbID" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbStatus" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbBattery" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt1" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt2" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt3" Row="3" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt4" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="pBStatus2" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pBStatus3" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pBStatus4" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="bnLight1" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="bnLight2" Row="2" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="bnLight4" Row="4" RowSpan="1" Column="5" ColumnSpan="1" /></Controls><Columns Styles="Percent,48.95498,Percent,26.82658,Percent,24.21844,AutoSize,0,AutoSize,0,Absolute,84" /><Rows Styles="AutoSize,0,Percent,25,Percent,25,Percent,25,Percent,25" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="bnLight3" Row="3" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="pBStatus1" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbPad1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPad2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="bnEditC3" Row="3" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="bnEditC4" Row="4" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="lbPad3" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPad4" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="cBController1" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="bnEditC2" Row="2" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="cBController2" Row="2" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="cBController3" Row="3" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="bnEditC1" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="cBController4" Row="4" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="lbSelectedProfile" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="lbID" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbStatus" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbBattery" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt1" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt2" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt3" Row="3" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt4" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="pBStatus2" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pBStatus3" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pBStatus4" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="bnLight1" Row="1" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="bnLight2" Row="2" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="bnLight4" Row="4" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="lbLinkProfile" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB1" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB2" Row="2" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB3" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB4" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /></Controls><Columns Styles="Percent,58.35329,Percent,21.22288,Percent,20.42383,Absolute,80,AutoSize,0,Absolute,40,Absolute,103" /><Rows Styles="AutoSize,0,Percent,25,Percent,25,Percent,25,Percent,25" /></TableLayoutSettings> Fill @@ -2971,7 +3142,7 @@ 904, 415 - 459, 229 + 630, 229 DS4Windows @@ -3214,7 +3385,7 @@ advColorDialog - DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.70.0, Culture=neutral, PublicKeyToken=null + DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.99.0, Culture=neutral, PublicKeyToken=null DS4Form diff --git a/DS4Windows/DS4Forms/DupBox.es.resx b/DS4Windows/DS4Forms/DupBox.es.resx index 3d3027e..ee9e85b 100644 --- a/DS4Windows/DS4Forms/DupBox.es.resx +++ b/DS4Windows/DS4Forms/DupBox.es.resx @@ -121,7 +121,7 @@ Guardar - <Escribe nuevo nombre aqui> + <Escribe el nuevo nombre aqui> Cancelar diff --git a/DS4Windows/DS4Forms/Hotkeys.cs b/DS4Windows/DS4Forms/Hotkeys.cs index 7f6afad..e8beea6 100644 --- a/DS4Windows/DS4Forms/Hotkeys.cs +++ b/DS4Windows/DS4Forms/Hotkeys.cs @@ -63,7 +63,7 @@ namespace DS4Windows private void linkJays2Kings_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - Process.Start("http://ds4windows.com"); + Process.Start("https://github.com/Jays2Kings/"); } private void linkElectro_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -88,13 +88,11 @@ namespace DS4Windows private void linkDonate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - //Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2FTZ9BZEHSQ8Q&lc=US&item_name=DS4Windows¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"); Process.Start("https://paypal.me/ryochan7"); } private void linkSourceCode_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - //Process.Start("https://github.com/Jays2Kings/DS4Windows"); Process.Start("https://github.com/Ryochan7/DS4Windows"); } diff --git a/DS4Windows/DS4Forms/Hotkeys.es.resx b/DS4Windows/DS4Forms/Hotkeys.es.resx index cead91f..3bd2708 100644 --- a/DS4Windows/DS4Forms/Hotkeys.es.resx +++ b/DS4Windows/DS4Forms/Hotkeys.es.resx @@ -140,23 +140,23 @@ 540, 458 - Ocultar Controlador DS4: Hides the DS4's regular input (Dinput) from other programs, check if you are getting double input in games or R2 pauses games -Click left side of touchpad: Left Touch -Click right side of touchpad: Right Touch -Click touchpad with 2 fingers: Multitouch -Click upper part of touchpad: Upper Touch -PS + Options o mantener PS por 10 segundos: Desconectar Controlador (Solo Bluetooth) -Tocar Touchpad + PS: Turn off touchpad movement (clicking still works) -Pad click on lower right: Right click (Best used when right side is used as a mouse button) -Two fingers up/down on touchpad*: Scroll Up/Down -Tap then hold touchpad*: Left mouse drag -2 finger touchpad swipe left or right: Cycle through profiles -Shift Modifer: Hold an action to use another set of controls -When mapping keyboard and mouse: -Toggle: The key will remain in a ""held down"" state until pressed again -Macro: Assign multiple keys to one input -Scan Code: Keys are interpreted differently. May be needed for certain games -*If enabled + Ocultar Control DS4: Oculta la entrada regular del DS4 (Dinput) de otros programas, comprueba si tienes doble entrada en juegos o que R2 pause juegos +Haga clic en el lado izquierdo del panel táctil: Toque izquierdo +Haga clic en el lado derecho del panel táctil: Toque derecho +Haga clic en el panel táctil con 2 dedos: Multi toque +Haga clic en la parte superior del panel táctil: Toque superior +PS + Options o mantener PS por 10 segundos: Desconectar Control (Solo Bluetooth) +Clic en el panel táctil + PS: Desactiva el movimiento del panel táctil (el clic sigue funcionando) +Clic en la parte inferior derecha del panel: Haga clic derecho (Mejor utilizado cuando el lado derecho se utiliza como un botón del ratón) +Dos dedos arriba / abajo en el panel táctil*: Desplazar hacia arriba / abajo +Toque y mantenga pulsado el panel táctil*: Arrastrar el ratón hacia la izquierda +Deslizar el dedo hacia la izquierda o la derecha: Ciclo a través de perfiles +Modificador de cambio: Realizar una acción para utilizar otro conjunto de controles +Al asignar el teclado y el ratón: +Palanca: La tecla permanecerá en estado "" presionado "" hasta que se vuelva a pulsar +Macro: Asignar varias teclas a una entrada +Código de exploración: Las claves se interpretan de manera diferente. Puede ser necesario para ciertos juegos +*Si está activado 563, 386 diff --git a/DS4Windows/DS4Forms/Hotkeys.resx b/DS4Windows/DS4Forms/Hotkeys.resx index d37f105..1c92517 100644 --- a/DS4Windows/DS4Forms/Hotkeys.resx +++ b/DS4Windows/DS4Forms/Hotkeys.resx @@ -190,7 +190,7 @@ 0 - DS4Windows - Jays2Kings Build (Version + DS4Windows - Ryochan7 Build (Version TopCenter @@ -483,685 +483,6 @@ 2 - - lbuk - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 0 - - - lbUkrainianT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 1 - - - lbid - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 2 - - - lbIndonesianT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 3 - - - lbhu - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 4 - - - lbHungarianT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 5 - - - lbel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 6 - - - lbGreekT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 7 - - - lbfi - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 8 - - - lbFinnishT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 9 - - - lbcs - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 10 - - - lbCzechT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 11 - - - lbpt - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 12 - - - lbPortugueseT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 13 - - - lbes - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 14 - - - lbSpanishT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 15 - - - lbpl - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 16 - - - lbPolishT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 17 - - - lbde - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 18 - - - lbGermanT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 19 - - - lbItalianT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 20 - - - lbitIT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 21 - - - lbruRU - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 22 - - - lbRussianT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 23 - - - lbroRO - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 24 - - - lbRomanianT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 25 - - - lbtr - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 26 - - - lbTurkishT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 27 - - - lbzhHans - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 28 - - - lbChineseST - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 29 - - - lbzhHant - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 30 - - - lbChineseTT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 31 - - - lbar - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 32 - - - lbArabicT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 33 - - - lbhe - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 34 - - - lbHebrewT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 35 - - - lbfrFR - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 36 - - - lbFrenchT - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tLPTranslators - - - 37 - - - Bottom - - - 3, 130 - - - 19 - - - 553, 301 - - - 19 - - - tLPTranslators - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tPCredits - - - 4 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="lbuk" Row="18" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbUkrainianT" Row="18" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbid" Row="17" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbIndonesianT" Row="17" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbhu" Row="16" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbHungarianT" Row="16" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbel" Row="15" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbGreekT" Row="15" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbfi" Row="14" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbFinnishT" Row="14" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbcs" Row="13" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbCzechT" Row="13" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbpt" Row="12" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPortugueseT" Row="12" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbes" Row="11" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbSpanishT" Row="11" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbpl" Row="10" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPolishT" Row="10" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbde" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbGermanT" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbItalianT" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbitIT" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbruRU" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbRussianT" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbroRO" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbRomanianT" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbtr" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbTurkishT" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbzhHans" Row="5" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbChineseST" Row="5" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbzhHant" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbChineseTT" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbar" Row="7" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbArabicT" Row="7" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbhe" Row="8" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbHebrewT" Row="8" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbfrFR" Row="9" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbFrenchT" Row="9" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0" /><Rows Styles="Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Absolute,16,Absolute,16,Absolute,16,Absolute,16,Absolute,16,Absolute,16,Absolute,16" /></TableLayoutSettings> - - - Bottom, Left - - - True - - - NoControl - - - 4, 114 - - - 59, 13 - - - 13 - - - Translators - - - lbTranslators - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tPCredits - - - 5 - - - True - - - NoControl - - - 72, 3 - - - 69, 13 - - - 18 - - - Source Code - - - linkSourceCode - - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tPCredits - - - 7 - - - True - - - Bottom - - - NoControl - - - 3, 431 - - - 103, 13 - - - 13 - - - Links displayed here - - - lbLinkText - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tPCredits - - - 8 - - - 4, 22 - - - 3, 3, 3, 3 - - - 559, 447 - - - 1 - - - Credits - - - tPCredits - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tCAbout - - - 1 - - - Fill - - - 0, 36 - - - 567, 473 - - - 22 - - - tCAbout - - - System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - - - Top - - - NoControl - - - 3, 3 - - - 536, 454 - - - 3 - - - Hide DS4 Controller: Hides the DS4's regular input (Dinput) from other programs, check if you are getting double input in games or R2 pauses games -Click left side of touchpad: Left Touch -Click right side of touchpad: Right Touch -Click touchpad with 2 fingers: Multitouch -Click upper part of touchpad: Upper Touch -PS + Options or hold PS for 10 secs: Disconnect Controller (Only on Bluetooth) -Touch Touchpad + PS: Turn off touchpad movement (clicking still works) -Pad click on lower right: Right click (Best used when right side is used as a mouse button) -Two fingers up/down on touchpad*: Scroll Up/Down -Tap then hold touchpad*: Left mouse drag -2 finger touchpad swipe left or right: Cycle through profiles -Shift Modifer: Hold an action to use another set of controls -When mapping keyboard and mouse: -Toggle: The key will remain in a "held down" state until pressed again -Macro: Assign multiple keys to one input -Scan Code: Keys are interpreted differently. May be needed for certain games -*If enabled - - - lbHotkeys - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tPHotkeys - - - 0 - True @@ -2362,6 +1683,229 @@ Scan Code: Keys are interpreted differently. May be needed for certain games 37 + + Bottom + + + 3, 130 + + + 19 + + + 553, 301 + + + 19 + + + tLPTranslators + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tPCredits + + + 4 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="lbuk" Row="18" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbUkrainianT" Row="18" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbid" Row="17" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbIndonesianT" Row="17" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbhu" Row="16" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbHungarianT" Row="16" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbel" Row="15" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbGreekT" Row="15" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbfi" Row="14" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbFinnishT" Row="14" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbcs" Row="13" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbCzechT" Row="13" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbpt" Row="12" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPortugueseT" Row="12" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbes" Row="11" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbSpanishT" Row="11" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbpl" Row="10" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPolishT" Row="10" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbde" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbGermanT" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbItalianT" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbitIT" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbruRU" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbRussianT" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbroRO" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbRomanianT" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbtr" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbTurkishT" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbzhHans" Row="5" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbChineseST" Row="5" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbzhHant" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbChineseTT" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbar" Row="7" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbArabicT" Row="7" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbhe" Row="8" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbHebrewT" Row="8" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbfrFR" Row="9" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbFrenchT" Row="9" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0" /><Rows Styles="Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Percent,8.333333,Absolute,16,Absolute,16,Absolute,16,Absolute,16,Absolute,16,Absolute,16,Absolute,16" /></TableLayoutSettings> + + + Bottom, Left + + + True + + + NoControl + + + 4, 114 + + + 59, 13 + + + 13 + + + Translators + + + lbTranslators + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tPCredits + + + 5 + + + True + + + NoControl + + + 72, 3 + + + 69, 13 + + + 18 + + + Source Code + + + linkSourceCode + + + System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tPCredits + + + 7 + + + True + + + Bottom + + + NoControl + + + 3, 431 + + + 103, 13 + + + 13 + + + Links displayed here + + + lbLinkText + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tPCredits + + + 8 + + + 4, 22 + + + 3, 3, 3, 3 + + + 559, 447 + + + 1 + + + Credits + + + tPCredits + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tCAbout + + + 1 + + + Fill + + + 0, 36 + + + 567, 473 + + + 22 + + + tCAbout + + + System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + Top + + + NoControl + + + 3, 3 + + + 536, 454 + + + 3 + + + Hide DS4 Controller: Hides the DS4's regular input (Dinput) from other programs, check if you are getting double input in games or R2 pauses games +Click left side of touchpad: Left Touch +Click right side of touchpad: Right Touch +Click touchpad with 2 fingers: Multitouch +Click upper part of touchpad: Upper Touch +PS + Options or hold PS for 10 secs: Disconnect Controller (Only on Bluetooth) +Touch Touchpad + PS: Turn off touchpad movement (clicking still works) +Pad click on lower right: Right click (Best used when right side is used as a mouse button) +Two fingers up/down on touchpad*: Scroll Up/Down +Tap then hold touchpad*: Left mouse drag +2 finger touchpad swipe left or right: Cycle through profiles +Shift Modifer: Hold an action to use another set of controls +When mapping keyboard and mouse: +Toggle: The key will remain in a "held down" state until pressed again +Macro: Assign multiple keys to one input +Scan Code: Keys are interpreted differently. May be needed for certain games +*If enabled + + + lbHotkeys + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tPHotkeys + + + 0 + True diff --git a/DS4Windows/DS4Forms/KBM360.es.resx b/DS4Windows/DS4Forms/KBM360.es.resx index 35fb542..c1499ef 100644 --- a/DS4Windows/DS4Forms/KBM360.es.resx +++ b/DS4Windows/DS4Forms/KBM360.es.resx @@ -161,7 +161,7 @@ 105, 17 - Controles X360 + Controles Xbox 360 112, 17 diff --git a/DS4Windows/DS4Forms/Options.Designer.cs b/DS4Windows/DS4Forms/Options.Designer.cs index 40e057b..06d0b29 100644 --- a/DS4Windows/DS4Forms/Options.Designer.cs +++ b/DS4Windows/DS4Forms/Options.Designer.cs @@ -76,6 +76,8 @@ this.nUDL2 = new System.Windows.Forms.NumericUpDown(); this.gBTouchpad = new System.Windows.Forms.GroupBox(); this.pnlTPMouse = new System.Windows.Forms.Panel(); + this.touchpadDisInvertButton = new System.Windows.Forms.Button(); + this.label25 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label(); this.touchpadInvertComboBox = new System.Windows.Forms.ComboBox(); this.cbStartTouchpadOff = new System.Windows.Forms.CheckBox(); @@ -361,6 +363,26 @@ this.shareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.cMTouchDisableInvert = new System.Windows.Forms.ContextMenuStrip(this.components); + this.crossTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.circleTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.squareTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.triangleTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.l1TouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.l2TouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.r1TouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.r2TouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.upTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.downTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.leftTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.rightTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.l3TouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.r3TouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.oneFingerTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.twoFingerTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.optionsTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.shareTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.psTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.advColorDialog = new DS4Windows.AdvancedColorDialog(); ((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit(); @@ -453,6 +475,7 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit(); this.cMGyroTriggers.SuspendLayout(); + this.cMTouchDisableInvert.SuspendLayout(); this.SuspendLayout(); // // lowColorChooserButton @@ -649,8 +672,6 @@ // cBTouchpadJitterCompensation // resources.ApplyResources(this.cBTouchpadJitterCompensation, "cBTouchpadJitterCompensation"); - this.cBTouchpadJitterCompensation.Checked = true; - this.cBTouchpadJitterCompensation.CheckState = System.Windows.Forms.CheckState.Checked; this.cBTouchpadJitterCompensation.ForeColor = System.Drawing.SystemColors.ControlLightLight; this.cBTouchpadJitterCompensation.Name = "cBTouchpadJitterCompensation"; this.cBTouchpadJitterCompensation.UseVisualStyleBackColor = true; @@ -911,6 +932,8 @@ // // pnlTPMouse // + this.pnlTPMouse.Controls.Add(this.touchpadDisInvertButton); + this.pnlTPMouse.Controls.Add(this.label25); this.pnlTPMouse.Controls.Add(this.label15); this.pnlTPMouse.Controls.Add(this.touchpadInvertComboBox); this.pnlTPMouse.Controls.Add(this.nUDScroll); @@ -926,6 +949,19 @@ resources.ApplyResources(this.pnlTPMouse, "pnlTPMouse"); this.pnlTPMouse.Name = "pnlTPMouse"; // + // touchpadDisInvertButton + // + this.touchpadDisInvertButton.ForeColor = System.Drawing.SystemColors.ControlText; + resources.ApplyResources(this.touchpadDisInvertButton, "touchpadDisInvertButton"); + this.touchpadDisInvertButton.Name = "touchpadDisInvertButton"; + this.touchpadDisInvertButton.UseVisualStyleBackColor = true; + this.touchpadDisInvertButton.Click += new System.EventHandler(this.touchpadDisInvertButton_Click); + // + // label25 + // + resources.ApplyResources(this.label25, "label25"); + this.label25.Name = "label25"; + // // label15 // resources.ApplyResources(this.label15, "label15"); @@ -3875,6 +3911,166 @@ resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem"); this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged); // + // cMTouchDisableInvert + // + this.cMTouchDisableInvert.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.crossTouchInvStripMenuItem, + this.circleTouchInvStripMenuItem, + this.squareTouchInvStripMenuItem, + this.triangleTouchInvStripMenuItem, + this.l1TouchInvStripMenuItem, + this.l2TouchInvStripMenuItem, + this.r1TouchInvStripMenuItem, + this.r2TouchInvStripMenuItem, + this.upTouchInvStripMenuItem, + this.downTouchInvStripMenuItem, + this.leftTouchInvStripMenuItem, + this.rightTouchInvStripMenuItem, + this.l3TouchInvStripMenuItem, + this.r3TouchInvStripMenuItem, + this.oneFingerTouchInvStripMenuItem, + this.twoFingerTouchInvStripMenuItem, + this.optionsTouchInvStripMenuItem, + this.shareTouchInvStripMenuItem, + this.psTouchInvStripMenuItem}); + this.cMTouchDisableInvert.Name = "cMTouchDisableInvert"; + this.cMTouchDisableInvert.ShowCheckMargin = true; + this.cMTouchDisableInvert.ShowImageMargin = false; + resources.ApplyResources(this.cMTouchDisableInvert, "cMTouchDisableInvert"); + // + // crossTouchInvStripMenuItem + // + this.crossTouchInvStripMenuItem.CheckOnClick = true; + this.crossTouchInvStripMenuItem.Name = "crossTouchInvStripMenuItem"; + resources.ApplyResources(this.crossTouchInvStripMenuItem, "crossTouchInvStripMenuItem"); + this.crossTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // circleTouchInvStripMenuItem + // + this.circleTouchInvStripMenuItem.CheckOnClick = true; + this.circleTouchInvStripMenuItem.Name = "circleTouchInvStripMenuItem"; + resources.ApplyResources(this.circleTouchInvStripMenuItem, "circleTouchInvStripMenuItem"); + this.circleTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // squareTouchInvStripMenuItem + // + this.squareTouchInvStripMenuItem.CheckOnClick = true; + this.squareTouchInvStripMenuItem.Name = "squareTouchInvStripMenuItem"; + resources.ApplyResources(this.squareTouchInvStripMenuItem, "squareTouchInvStripMenuItem"); + this.squareTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // triangleTouchInvStripMenuItem + // + this.triangleTouchInvStripMenuItem.CheckOnClick = true; + this.triangleTouchInvStripMenuItem.Name = "triangleTouchInvStripMenuItem"; + resources.ApplyResources(this.triangleTouchInvStripMenuItem, "triangleTouchInvStripMenuItem"); + this.triangleTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // l1TouchInvStripMenuItem + // + this.l1TouchInvStripMenuItem.CheckOnClick = true; + this.l1TouchInvStripMenuItem.Name = "l1TouchInvStripMenuItem"; + resources.ApplyResources(this.l1TouchInvStripMenuItem, "l1TouchInvStripMenuItem"); + this.l1TouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // l2TouchInvStripMenuItem + // + this.l2TouchInvStripMenuItem.CheckOnClick = true; + this.l2TouchInvStripMenuItem.Name = "l2TouchInvStripMenuItem"; + resources.ApplyResources(this.l2TouchInvStripMenuItem, "l2TouchInvStripMenuItem"); + this.l2TouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // r1TouchInvStripMenuItem + // + this.r1TouchInvStripMenuItem.CheckOnClick = true; + this.r1TouchInvStripMenuItem.Name = "r1TouchInvStripMenuItem"; + resources.ApplyResources(this.r1TouchInvStripMenuItem, "r1TouchInvStripMenuItem"); + this.r1TouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // r2TouchInvStripMenuItem + // + this.r2TouchInvStripMenuItem.CheckOnClick = true; + this.r2TouchInvStripMenuItem.Name = "r2TouchInvStripMenuItem"; + resources.ApplyResources(this.r2TouchInvStripMenuItem, "r2TouchInvStripMenuItem"); + this.r2TouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // upTouchInvStripMenuItem + // + this.upTouchInvStripMenuItem.CheckOnClick = true; + this.upTouchInvStripMenuItem.Name = "upTouchInvStripMenuItem"; + resources.ApplyResources(this.upTouchInvStripMenuItem, "upTouchInvStripMenuItem"); + this.upTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // downTouchInvStripMenuItem + // + this.downTouchInvStripMenuItem.CheckOnClick = true; + this.downTouchInvStripMenuItem.Name = "downTouchInvStripMenuItem"; + resources.ApplyResources(this.downTouchInvStripMenuItem, "downTouchInvStripMenuItem"); + this.downTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // leftTouchInvStripMenuItem + // + this.leftTouchInvStripMenuItem.CheckOnClick = true; + this.leftTouchInvStripMenuItem.Name = "leftTouchInvStripMenuItem"; + resources.ApplyResources(this.leftTouchInvStripMenuItem, "leftTouchInvStripMenuItem"); + this.leftTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // rightTouchInvStripMenuItem + // + this.rightTouchInvStripMenuItem.CheckOnClick = true; + this.rightTouchInvStripMenuItem.Name = "rightTouchInvStripMenuItem"; + resources.ApplyResources(this.rightTouchInvStripMenuItem, "rightTouchInvStripMenuItem"); + this.rightTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // l3TouchInvStripMenuItem + // + this.l3TouchInvStripMenuItem.CheckOnClick = true; + this.l3TouchInvStripMenuItem.Name = "l3TouchInvStripMenuItem"; + resources.ApplyResources(this.l3TouchInvStripMenuItem, "l3TouchInvStripMenuItem"); + this.l3TouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // r3TouchInvStripMenuItem + // + this.r3TouchInvStripMenuItem.CheckOnClick = true; + this.r3TouchInvStripMenuItem.Name = "r3TouchInvStripMenuItem"; + resources.ApplyResources(this.r3TouchInvStripMenuItem, "r3TouchInvStripMenuItem"); + this.r3TouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // oneFingerTouchInvStripMenuItem + // + this.oneFingerTouchInvStripMenuItem.CheckOnClick = true; + this.oneFingerTouchInvStripMenuItem.Name = "oneFingerTouchInvStripMenuItem"; + resources.ApplyResources(this.oneFingerTouchInvStripMenuItem, "oneFingerTouchInvStripMenuItem"); + this.oneFingerTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // twoFingerTouchInvStripMenuItem + // + this.twoFingerTouchInvStripMenuItem.CheckOnClick = true; + this.twoFingerTouchInvStripMenuItem.Name = "twoFingerTouchInvStripMenuItem"; + resources.ApplyResources(this.twoFingerTouchInvStripMenuItem, "twoFingerTouchInvStripMenuItem"); + this.twoFingerTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // optionsTouchInvStripMenuItem + // + this.optionsTouchInvStripMenuItem.CheckOnClick = true; + this.optionsTouchInvStripMenuItem.Name = "optionsTouchInvStripMenuItem"; + resources.ApplyResources(this.optionsTouchInvStripMenuItem, "optionsTouchInvStripMenuItem"); + this.optionsTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // shareTouchInvStripMenuItem + // + this.shareTouchInvStripMenuItem.CheckOnClick = true; + this.shareTouchInvStripMenuItem.Name = "shareTouchInvStripMenuItem"; + resources.ApplyResources(this.shareTouchInvStripMenuItem, "shareTouchInvStripMenuItem"); + this.shareTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // + // psTouchInvStripMenuItem + // + this.psTouchInvStripMenuItem.CheckOnClick = true; + this.psTouchInvStripMenuItem.Name = "psTouchInvStripMenuItem"; + resources.ApplyResources(this.psTouchInvStripMenuItem, "psTouchInvStripMenuItem"); + this.psTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); + // // Options // resources.ApplyResources(this, "$this"); @@ -3996,6 +4192,7 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit(); this.cMGyroTriggers.ResumeLayout(false); + this.cMTouchDisableInvert.ResumeLayout(false); this.ResumeLayout(false); } @@ -4336,5 +4533,27 @@ private System.Windows.Forms.ComboBox cBSixaxisXOutputCurve; private System.Windows.Forms.Label label24; private System.Windows.Forms.Label label23; + private System.Windows.Forms.ContextMenuStrip cMTouchDisableInvert; + private System.Windows.Forms.ToolStripMenuItem crossTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem circleTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem squareTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem triangleTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem l1TouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem l2TouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem r1TouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem r2TouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem upTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem downTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem leftTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem rightTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem l3TouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem r3TouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem oneFingerTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem twoFingerTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem optionsTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem shareTouchInvStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem psTouchInvStripMenuItem; + private System.Windows.Forms.Button touchpadDisInvertButton; + private System.Windows.Forms.Label label25; } } \ No newline at end of file diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index c083b14..b385f99 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -614,6 +614,16 @@ namespace DS4Windows nUDRSCurve.Value = RSCurve[device]; cBControllerInput.Checked = DS4Mapping; + for (int i = 0, arlen = cMGyroTriggers.Items.Count; i < arlen; i++) + { + ((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked = false; + } + + for (int i = 0, arlen = cMTouchDisableInvert.Items.Count; i < arlen; i++) + { + ((ToolStripMenuItem)cMTouchDisableInvert.Items[i]).Checked = false; + } + string[] satriggers = SATriggers[device].Split(','); List s = new List(); int gyroTriggerCount = cMGyroTriggers.Items.Count; @@ -641,6 +651,26 @@ namespace DS4Windows break; } } + + btnGyroTriggers.Text = string.Join(", ", s); + s.Clear(); + + int[] touchDisInvTriggers = TouchDisInvertTriggers[device]; + int touchDisableInvCount = cMTouchDisableInvert.Items.Count; + for (int i = 0, trigLen = touchDisInvTriggers.Length; i < trigLen; i++) + { + int tr = touchDisInvTriggers[i]; + if (tr < touchDisableInvCount && tr > -1) + { + ToolStripMenuItem current = (ToolStripMenuItem)cMTouchDisableInvert.Items[tr]; + current.Checked = true; + s.Add(current.Text); + } + } + + if (s.Count > 0) + touchpadDisInvertButton.Text = string.Join(", ", s); + nUDGyroSensitivity.Value = GyroSensitivity[device]; gyroTriggerBehavior.Checked = GyroTriggerTurns[device]; nUDGyroMouseVertScale.Value = GyroSensVerticalScale[device]; @@ -744,7 +774,18 @@ namespace DS4Windows nUDLSCurve.Value = 0; nUDRSCurve.Value = 0; cBControllerInput.Checked = DS4Mapping; + + for (int i = 0, arlen = cMGyroTriggers.Items.Count - 1; i < arlen; i++) + { + ((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked = false; + } ((ToolStripMenuItem)cMGyroTriggers.Items[cMGyroTriggers.Items.Count - 1]).Checked = true; + + for (int i = 0, arlen = cMTouchDisableInvert.Items.Count; i < arlen; i++) + { + ((ToolStripMenuItem)cMTouchDisableInvert.Items[i]).Checked = false; + } + nUDGyroSensitivity.Value = 100; nUDGyroMouseVertScale.Value = 100; gyroTriggerBehavior.Checked = true; @@ -1022,42 +1063,38 @@ namespace DS4Windows if (Form.ActiveForm == root && cBControllerInput.Checked && tCControls.SelectedIndex < 1) { int tempDeviceNum = (int)nUDSixaxis.Value - 1; - switch (Program.rootHub.GetInputkeys(tempDeviceNum)) + switch (Program.rootHub.GetActiveInputControl(tempDeviceNum)) { - case ("nothing"): break; - case ("Cross"): Show_ControlsBn(bnCross, e); break; - case ("Circle"): Show_ControlsBn(bnCircle, e); break; - case ("Square"): Show_ControlsBn(bnSquare, e); break; - case ("Triangle"): Show_ControlsBn(bnTriangle, e); break; - case ("Options"): Show_ControlsBn(bnOptions, e); break; - case ("Share"): Show_ControlsBn(bnShare, e); break; - case ("Up"): Show_ControlsBn(bnUp, e); break; - case ("Down"): Show_ControlsBn(bnDown, e); break; - case ("Left"): Show_ControlsBn(bnLeft, e); break; - case ("Right"): Show_ControlsBn(bnRight, e); break; - case ("PS"): Show_ControlsBn(bnPS, e); break; - case ("L1"): Show_ControlsBn(bnL1, e); break; - case ("R1"): Show_ControlsBn(bnR1, e); break; - case ("L2"): Show_ControlsBn(bnL2, e); break; - case ("R2"): Show_ControlsBn(bnR2, e); break; - case ("L3"): Show_ControlsBn(bnL3, e); break; - case ("R3"): Show_ControlsBn(bnR3, e); break; - case ("Touch Left"): Show_ControlsBn(bnTouchLeft, e); break; - case ("Touch Right"): Show_ControlsBn(bnTouchRight, e); break; - case ("Touch Multi"): Show_ControlsBn(bnTouchMulti, e); break; - case ("Touch Upper"): Show_ControlsBn(bnTouchUpper, e); break; - case ("LS Up"): Show_ControlsBn(bnLSUp, e); break; - case ("LS Down"): Show_ControlsBn(bnLSDown, e); break; - case ("LS Left"): Show_ControlsBn(bnLSLeft, e); break; - case ("LS Right"): Show_ControlsBn(bnLSRight, e); break; - case ("RS Up"): Show_ControlsBn(bnRSUp, e); break; - case ("RS Down"): Show_ControlsBn(bnRSDown, e); break; - case ("RS Left"): Show_ControlsBn(bnRSLeft, e); break; - case ("RS Right"): Show_ControlsBn(bnRSRight, e); break; - case ("GyroXP"): Show_ControlsBn(bnGyroXP, e); break; - case ("GyroXN"): Show_ControlsBn(bnGyroXN, e); break; - case ("GyroZP"): Show_ControlsBn(bnGyroZP, e); break; - case ("GyroZN"): Show_ControlsBn(bnGyroZN, e); break; + case DS4Controls.None: break; + case DS4Controls.Cross: Show_ControlsBn(bnCross, e); break; + case DS4Controls.Circle: Show_ControlsBn(bnCircle, e); break; + case DS4Controls.Square: Show_ControlsBn(bnSquare, e); break; + case DS4Controls.Triangle: Show_ControlsBn(bnTriangle, e); break; + case DS4Controls.Options: Show_ControlsBn(bnOptions, e); break; + case DS4Controls.Share: Show_ControlsBn(bnShare, e); break; + case DS4Controls.DpadUp: Show_ControlsBn(bnUp, e); break; + case DS4Controls.DpadDown: Show_ControlsBn(bnDown, e); break; + case DS4Controls.DpadLeft: Show_ControlsBn(bnLeft, e); break; + case DS4Controls.DpadRight: Show_ControlsBn(bnRight, e); break; + case DS4Controls.PS: Show_ControlsBn(bnPS, e); break; + case DS4Controls.L1: Show_ControlsBn(bnL1, e); break; + case DS4Controls.R1: Show_ControlsBn(bnR1, e); break; + case DS4Controls.L2: Show_ControlsBn(bnL2, e); break; + case DS4Controls.R2: Show_ControlsBn(bnR2, e); break; + case DS4Controls.L3: Show_ControlsBn(bnL3, e); break; + case DS4Controls.R3: Show_ControlsBn(bnR3, e); break; + case DS4Controls.TouchLeft: Show_ControlsBn(bnTouchLeft, e); break; + case DS4Controls.TouchRight: Show_ControlsBn(bnTouchRight, e); break; + case DS4Controls.TouchMulti: Show_ControlsBn(bnTouchMulti, e); break; + case DS4Controls.TouchUpper: Show_ControlsBn(bnTouchUpper, e); break; + case DS4Controls.LYNeg: Show_ControlsBn(bnLSUp, e); break; + case DS4Controls.LYPos: Show_ControlsBn(bnLSDown, e); break; + case DS4Controls.LXNeg: Show_ControlsBn(bnLSLeft, e); break; + case DS4Controls.LXPos: Show_ControlsBn(bnLSRight, e); break; + case DS4Controls.RYNeg: Show_ControlsBn(bnRSUp, e); break; + case DS4Controls.RYPos: Show_ControlsBn(bnRSDown, e); break; + case DS4Controls.RXNeg: Show_ControlsBn(bnRSLeft, e); break; + case DS4Controls.RXPos: Show_ControlsBn(bnRSRight, e); break; default: break; } } @@ -1116,57 +1153,6 @@ namespace DS4Windows { lBControls.SelectedIndex = tempIndex; } - - /*switch (name) - { - #region - case "bnCross": lBControls.SelectedIndex = 0; break; - case "bnCircle": lBControls.SelectedIndex = 1; break; - case "bnSquare": lBControls.SelectedIndex = 2; break; - case "bnTriangle": lBControls.SelectedIndex = 3; break; - case "bnOptions": lBControls.SelectedIndex = 4; break; - case "bnShare": lBControls.SelectedIndex = 5; break; - case "bnUp": lBControls.SelectedIndex = 6; break; - case "bnDown": lBControls.SelectedIndex = 7; break; - case "bnLeft": lBControls.SelectedIndex = 8; break; - case "bnRight": lBControls.SelectedIndex = 9; break; - case "bnPS": lBControls.SelectedIndex = 10; break; - case "bnL1": lBControls.SelectedIndex = 11; break; - case "bnR1": lBControls.SelectedIndex = 12; break; - case "bnL2": lBControls.SelectedIndex = 13; break; - case "bnR2": lBControls.SelectedIndex = 14; break; - case "bnL3": lBControls.SelectedIndex = 15; break; - case "bnR3": lBControls.SelectedIndex = 16; break; - case "bnTouchLeft": lBControls.SelectedIndex = 17; break; - case "bnTouchRight": lBControls.SelectedIndex = 18; break; - case "bnTouchMulti": lBControls.SelectedIndex = 19; break; - case "bnTouchUpper": lBControls.SelectedIndex = 20; break; - case "bnLSUp": lBControls.SelectedIndex = 21; break; - case "bnLSDown": lBControls.SelectedIndex = 22; break; - case "bnLSLeft": lBControls.SelectedIndex = 23; break; - case "bnLSRight": lBControls.SelectedIndex = 24; break; - case "bnRSUp": lBControls.SelectedIndex = 25; break; - case "bnRSDown": lBControls.SelectedIndex = 26; break; - case "bnRSLeft": lBControls.SelectedIndex = 27; break; - case "bnRSRight": lBControls.SelectedIndex = 28; break; - case "bnGyroZN": lBControls.SelectedIndex = 29; break; - case "bnGyroZP": lBControls.SelectedIndex = 30; break; - case "bnGyroXP": lBControls.SelectedIndex = 31; break; - case "bnGyroXN": lBControls.SelectedIndex = 32; break; - #endregion - } - - if (swipesOn) - { - switch (name) - { - case "bnSwipeUp": if (swipesOn) lBControls.SelectedIndex = 33; break; - case "bnSwipeDown": if (swipesOn) lBControls.SelectedIndex = 34; break; - case "bnSwipeLeft": if (swipesOn) lBControls.SelectedIndex = 35; break; - case "bnSwipeRight": if (swipesOn) lBControls.SelectedIndex = 36; break; - } - } - */ } DS4ControlSettings dcs = getDS4CSetting(device, name); @@ -1196,129 +1182,6 @@ namespace DS4Windows pBHoveredButton.Location = tempLabel.Location; } - /*switch (name) - { - #region - case "bnCross": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Cross; - pBHoveredButton.Location = lbLCross.Location; - break; - case "bnCircle": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Circle; - pBHoveredButton.Location = lbLCircle.Location; - break; - case "bnSquare": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Square; - pBHoveredButton.Location = lbLSquare.Location; - break; - case "bnTriangle": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Triangle; - pBHoveredButton.Location = lbLTriangle.Location; - break; - case "bnOptions": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Options; - pBHoveredButton.Location = lbLOptions.Location; - break; - case "bnShare": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Share; - pBHoveredButton.Location = lbLShare.Location; - break; - case "bnUp": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Up; - pBHoveredButton.Location = lbLUp.Location; - break; - case "bnDown": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Down; - pBHoveredButton.Location = lbLDown.Location; - break; - case "bnLeft": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Left; - pBHoveredButton.Location = lbLLeft.Location; - break; - case "bnRight": - pBHoveredButton.Image = Properties.Resources.DS4_Config_Right; - pBHoveredButton.Location = lbLright.Location; - break; - case "bnPS": - pBHoveredButton.Image = Properties.Resources.DS4_Config_PS; - pBHoveredButton.Location = lbLPS.Location; - break; - case "bnL1": - pBHoveredButton.Image = Properties.Resources.DS4_Config_L1; - pBHoveredButton.Location = lbLL1.Location; - break; - case "bnR1": - pBHoveredButton.Image = Properties.Resources.DS4_Config_R1; - pBHoveredButton.Location = lbLR1.Location; - break; - case "bnL2": - pBHoveredButton.Image = Properties.Resources.DS4_Config_L2; - pBHoveredButton.Location = lbLL2.Location; - break; - case "bnR2": - pBHoveredButton.Image = Properties.Resources.DS4_Config_R2; - pBHoveredButton.Location = lbLR2.Location; - break; - case "bnTouchLeft": - pBHoveredButton.Image = Properties.Resources.DS4_Config_TouchLeft; - pBHoveredButton.Location = lbLTouchLM.Location; - break; - case "bnTouchRight": - pBHoveredButton.Image = Properties.Resources.DS4_Config_TouchRight; - pBHoveredButton.Location = lbLTouchRight.Location; - break; - case "bnTouchMulti": - pBHoveredButton.Image = Properties.Resources.DS4_Config_TouchMulti; - pBHoveredButton.Location = lbLTouchLM.Location; - break; - case "bnTouchUpper": - pBHoveredButton.Image = Properties.Resources.DS4_Config_TouchUpper; - pBHoveredButton.Location = lbLTouchUpper.Location; - break; - case "bnL3": - pBHoveredButton.Image = Properties.Resources.DS4_Config_LS; - pBHoveredButton.Location = lbLLS.Location; - break; - case "bnLSUp": - pBHoveredButton.Image = Properties.Resources.DS4_Config_LS; - pBHoveredButton.Location = lbLLS.Location; - break; - case "bnLSDown": - pBHoveredButton.Image = Properties.Resources.DS4_Config_LS; - pBHoveredButton.Location = lbLLS.Location; - break; - case "bnLSLeft": - pBHoveredButton.Image = Properties.Resources.DS4_Config_LS; - pBHoveredButton.Location = lbLLS.Location; - break; - case "bnLSRight": - pBHoveredButton.Image = Properties.Resources.DS4_Config_LS; - pBHoveredButton.Location = lbLLS.Location; - break; - case "bnR3": - pBHoveredButton.Image = Properties.Resources.DS4_Config_RS; - pBHoveredButton.Location = lbLRS.Location; - break; - case "bnRSUp": - pBHoveredButton.Image = Properties.Resources.DS4_Config_RS; - pBHoveredButton.Location = lbLRS.Location; - break; - case "bnRSDown": - pBHoveredButton.Image = Properties.Resources.DS4_Config_RS; - pBHoveredButton.Location = lbLRS.Location; - break; - case "bnRSLeft": - pBHoveredButton.Image = Properties.Resources.DS4_Config_RS; - pBHoveredButton.Location = lbLRS.Location; - break; - case "bnRSRight": - pBHoveredButton.Image = Properties.Resources.DS4_Config_RS; - pBHoveredButton.Location = lbLRS.Location; - break; - #endregion - } - */ - if (pBHoveredButton.Image != null) pBHoveredButton.Size = new Size((int)(pBHoveredButton.Image.Size.Width * (dpix / 1.25f)), (int)(pBHoveredButton.Image.Size.Height * (dpix / 1.25f))); } @@ -1445,6 +1308,18 @@ namespace DS4Windows SATriggers[device] = string.Join(",", ints); + ints.Clear(); + for (int i = 0, trigLen = cMTouchDisableInvert.Items.Count; i < trigLen; i++) + { + if (((ToolStripMenuItem)cMTouchDisableInvert.Items[i]).Checked) + ints.Add(i); + } + + if (ints.Count == 0) + ints.Add(-1); + + TouchDisInvertTriggers[device] = ints.ToArray(); + if (nUDRainbow.Value == 0) btnRainbow.Image = greyscale; else btnRainbow.Image = colored; } @@ -1484,36 +1359,6 @@ namespace DS4Windows } } - /*public void Toggle_Bn(bool SC, bool TG, bool MC, bool MR) - { - if (lastSelected.Tag is KeyValuePair || lastSelected.Tag is KeyValuePair || lastSelected.Tag is KeyValuePair) - lastSelected.Font = new Font(lastSelected.Font, - (SC ? FontStyle.Bold : FontStyle.Regular) | (TG ? FontStyle.Italic : FontStyle.Regular) | - (MC ? FontStyle.Underline : FontStyle.Regular) | (MR ? FontStyle.Strikeout : FontStyle.Regular)); - else if (lastSelected.Tag is KeyValuePair) - if (lastSelected.Tag.ToString().Contains("Mouse Button")) - lastSelected.Font = new Font(lastSelected.Font, TG ? FontStyle.Italic : FontStyle.Regular); - else - lastSelected.Font = new Font(lastSelected.Font, FontStyle.Regular); - } - - public void Toggle_Bn(bool SC, bool TG, bool MC, bool MR, System.Windows.Forms.Control ctrl) - { - if (ctrl is Button) - { - Button btn = (Button)ctrl; - if (btn.Tag is KeyValuePair || btn.Tag is KeyValuePair || btn.Tag is KeyValuePair) - btn.Font = new Font(btn.Font, - (SC ? FontStyle.Bold : FontStyle.Regular) | (TG ? FontStyle.Italic : FontStyle.Regular) | - (MC ? FontStyle.Underline : FontStyle.Regular) | (MR ? FontStyle.Strikeout : FontStyle.Regular)); - else if (btn.Tag is KeyValuePair) - if (btn.Tag.ToString().Contains("Mouse Button")) - btn.Font = new Font(btn.Font, TG ? FontStyle.Italic : FontStyle.Regular); - else - btn.Font = new Font(btn.Font, FontStyle.Regular); - } - }*/ - private void btnLightbar_Click(object sender, EventArgs e) { advColorDialog.Color = Color.FromArgb(tBRedBar.Value, tBGreenBar.Value, tBBlueBar.Value); @@ -1759,7 +1604,7 @@ namespace DS4Windows if (olddinputcheck != cBDinput.Checked) { root.btnStartStop_Clicked(false); - root.btnStartStop_Clicked(false); + finishDInputChange(); } if (btnRumbleHeavyTest.Text == Properties.Resources.StopText) @@ -1835,6 +1680,7 @@ namespace DS4Windows public void UpdateLists() { + lBControls.BeginUpdate(); lBControls.Items[0] = "Cross : " + UpdateButtonList(bnCross); lBControls.Items[1] = "Circle : " + UpdateButtonList(bnCircle); lBControls.Items[2] = "Square : " + UpdateButtonList(bnSquare); @@ -1881,6 +1727,8 @@ namespace DS4Windows lbSwipeRight.Text = UpdateButtonList(bnSwipeRight); } + lBControls.EndUpdate(); + lbGyroXN.Text = UpdateButtonList(bnGyroXN); lbGyroZN.Text = UpdateButtonList(bnGyroZN); lbGyroZP.Text = UpdateButtonList(bnGyroZP); @@ -2280,10 +2128,23 @@ namespace DS4Windows if (!loading && device < 4) { root.btnStartStop_Clicked(false); - root.btnStartStop_Clicked(false); + finishDInputChange(); } } + private async void finishDInputChange() + { + await System.Threading.Tasks.Task.Factory.StartNew(() => + { + while (root.ChangingService) + { + System.Threading.Thread.Sleep(10); + } + }); + + root.btnStartStop_Clicked(false); + } + private void cbStartTouchpadOff_CheckedChanged(object sender, EventArgs e) { StartTouchpadOff[device] = cbStartTouchpadOff.Checked; @@ -2370,10 +2231,12 @@ namespace DS4Windows } else if (rBTPMouse.Checked && lBControls.Items.Count > 33) { + lBControls.BeginUpdate(); lBControls.Items.RemoveAt(36); lBControls.Items.RemoveAt(35); lBControls.Items.RemoveAt(34); lBControls.Items.RemoveAt(33); + lBControls.EndUpdate(); } } @@ -2451,14 +2314,6 @@ namespace DS4Windows MouseToolStripMenuItem.Visible = !(name == "lbTPSwipes" || name.StartsWith("bnSwipe")); } - /*private void BatchToggle_Bn(bool scancode, Button button1, Button button2, Button button3, Button button4) - { - Toggle_Bn(scancode, false, false, false, button1); - Toggle_Bn(scancode, false, false, false, button2); - Toggle_Bn(scancode, false, false, false, button3); - Toggle_Bn(scancode, false, false, false, button4); - }*/ - private void SetPreset(object sender, EventArgs e) { bool scancode = false; @@ -2728,37 +2583,45 @@ namespace DS4Windows private void btnGyroTriggers_Click(object sender, EventArgs e) { - cMGyroTriggers.Show((Control)sender, new Point(0, ((Control)sender).Height)); + Control button = (Control)sender; + cMGyroTriggers.Show(button, new Point(0, button.Height)); } private void SATrigger_CheckedChanged(object sender, EventArgs e) { - if (sender != cMGyroTriggers.Items[cMGyroTriggers.Items.Count - 1] && ((ToolStripMenuItem)sender).Checked) - ((ToolStripMenuItem)cMGyroTriggers.Items[cMGyroTriggers.Items.Count - 1]).Checked = false; - if (((ToolStripMenuItem)cMGyroTriggers.Items[cMGyroTriggers.Items.Count - 1]).Checked) //always on - for (int i = 0; i < cMGyroTriggers.Items.Count - 1; i++) - ((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked = false; - - List ints = new List(); - List s = new List(); - for (int i = 0; i < cMGyroTriggers.Items.Count - 1; i++) + if (loading == false) { - if (((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked) + int gyroTriggerCount = cMGyroTriggers.Items.Count; + if (sender != cMGyroTriggers.Items[gyroTriggerCount - 1] && ((ToolStripMenuItem)sender).Checked) + ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = false; + + if (((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked) //always on { - ints.Add(i); - s.Add(cMGyroTriggers.Items[i].Text); + for (int i = 0; i < gyroTriggerCount - 1; i++) + ((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked = false; } - } - if (ints.Count == 0) - { - ints.Add(-1); - s.Add(cMGyroTriggers.Items[cMGyroTriggers.Items.Count - 1].Text); - } + List ints = new List(); + List s = new List(); + for (int i = 0; i < gyroTriggerCount - 1; i++) + { + if (((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked) + { + ints.Add(i); + s.Add(cMGyroTriggers.Items[i].Text); + } + } - SATriggers[device] = string.Join(",", ints); - if (s.Count > 0) - btnGyroTriggers.Text = string.Join(", ", s); + if (ints.Count == 0) + { + ints.Add(-1); + s.Add(cMGyroTriggers.Items[gyroTriggerCount - 1].Text); + } + + SATriggers[device] = string.Join(",", ints); + if (s.Count > 0) + btnGyroTriggers.Text = string.Join(", ", s); + } } private void cBGyroInvert_CheckChanged(object sender, EventArgs e) @@ -3042,6 +2905,42 @@ namespace DS4Windows } } + private void TouchDisableInvert_CheckedChanged(object sender, EventArgs e) + { + if (loading == false) + { + int touchDisableInvCount = cMTouchDisableInvert.Items.Count; + + List ints = new List(); + List s = new List(); + for (int i = 0; i < touchDisableInvCount; i++) + { + ToolStripMenuItem current = (ToolStripMenuItem)cMTouchDisableInvert.Items[i]; + if (current.Checked) + { + ints.Add(i); + s.Add(current.Text); + } + } + + if (ints.Count == 0) + { + ints.Add(-1); + s.Add("None"); + } + + TouchDisInvertTriggers[device] = ints.ToArray(); + if (s.Count > 0) + touchpadDisInvertButton.Text = string.Join(", ", s); + } + } + + private void touchpadDisInvertButton_Click(object sender, EventArgs e) + { + Control button = (Control)sender; + cMTouchDisableInvert.Show(button, new Point(0, button.Height)); + } + private void Options_Resize(object sender, EventArgs e) { fLPSettings.AutoScroll = false; @@ -3054,7 +2953,6 @@ namespace DS4Windows if (lBControls.SelectedItem != null) { - //lbControlName.Text = lBControls.SelectedItem.ToString(); if (controlSelectedIndex == 0) lbControlName.ForeColor = Color.FromArgb(153, 205, 204); else if (controlSelectedIndex == 1) diff --git a/DS4Windows/DS4Forms/Options.es.resx b/DS4Windows/DS4Forms/Options.es.resx index e2c413a..5f80628 100644 --- a/DS4Windows/DS4Forms/Options.es.resx +++ b/DS4Windows/DS4Forms/Options.es.resx @@ -185,7 +185,7 @@ 158, 21 - Compensación Jitter + Compensación de nervios 257, 56 @@ -386,7 +386,7 @@ 202, 21 - Lanzar Programa con perfil + Abrir Programa con el perfil Explorar... @@ -395,7 +395,7 @@ 129, 17 - Utilizar Controlador + Utilizar Control 227, 11 @@ -413,7 +413,7 @@ 164, 21 - para Mapeo y lectura + para asignación y lectura 173, 21 @@ -461,7 +461,7 @@ Barra de luz - Prueba Ligera + Prueba Rapida Vibración @@ -497,7 +497,7 @@ 212, 156 - Lecturas del Controlador + Lecturas del Control (nada)/Shift desactivado @@ -512,7 +512,7 @@ 164, 17 - para usar estos contoles + para usar estos controles Modificador de Shift @@ -563,10 +563,10 @@ Dpad - Un dedo en el Touchpad + Un dedo en el panel táctil - Dos dedos en el Touchpad + Dos dedos en el panel táctil Sensibilidad diff --git a/DS4Windows/DS4Forms/Options.resx b/DS4Windows/DS4Forms/Options.resx index 7aa233b..31bc8ab 100644 --- a/DS4Windows/DS4Forms/Options.resx +++ b/DS4Windows/DS4Forms/Options.resx @@ -430,7 +430,7 @@ pnlTPMouse - 3 + 5 True @@ -463,7 +463,7 @@ pnlTPMouse - 8 + 10 63, 39 @@ -484,7 +484,7 @@ pnlTPMouse - 6 + 8 True @@ -517,7 +517,7 @@ pnlTPMouse - 4 + 6 True @@ -550,7 +550,7 @@ pnlTPMouse - 9 + 11 167, 9 @@ -571,7 +571,7 @@ pnlTPMouse - 2 + 4 63, 9 @@ -592,7 +592,7 @@ pnlTPMouse - 10 + 12 True @@ -658,7 +658,7 @@ pnlTPMouse - 7 + 9 True @@ -691,7 +691,7 @@ pnlTPMouse - 5 + 7 True @@ -1335,6 +1335,63 @@ 1 + + NoControl + + + 162, 103 + + + 101, 23 + + + 237 + + + None + + + touchpadDisInvertButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pnlTPMouse + + + 0 + + + True + + + NoControl + + + 141, 87 + + + 75, 13 + + + 236 + + + Disable Invert: + + + label25 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pnlTPMouse + + + 1 + True @@ -1363,7 +1420,7 @@ pnlTPMouse - 0 + 2 None @@ -1378,10 +1435,10 @@ Both X and Y Axes - 144, 82 + 178, 62 - 121, 21 + 85, 21 234 @@ -1396,7 +1453,7 @@ pnlTPMouse - 1 + 3 True @@ -1426,7 +1483,7 @@ pnlTPMouse - 11 + 13 -3, 39 @@ -6080,7 +6137,7 @@ with profile $this - 3 + 4 4, 22 @@ -8498,7 +8555,7 @@ with profile $this - 2 + 3 482, 17 @@ -8632,12 +8689,141 @@ with profile System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 144, 63 + + + 194, 22 + + + Cross + + + 194, 22 + + + Circle + + + 194, 22 + + + Square + + + 194, 22 + + + Triangle + + + 194, 22 + + + L1 + + + 194, 22 + + + L2 + + + 194, 22 + + + R1 + + + 194, 22 + + + R2 + + + 194, 22 + + + Up + + + 194, 22 + + + Down + + + 194, 22 + + + Left + + + 194, 22 + + + Right + + + 194, 22 + + + L3 + + + 194, 22 + + + R3 + + + 194, 22 + + + Finger on Touchpad + + + 194, 22 + + + 2 Fingers on Touchpad + + + 194, 22 + + + Options + + + 194, 22 + + + Share + + + 194, 22 + + + PS + + + 195, 422 + + + cMTouchDisableInvert + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 647, 17 True + + 176 + 96, 96 @@ -8947,11 +9133,125 @@ with profile System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + crossTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + circleTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + squareTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + triangleTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + l1TouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + l2TouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + r1TouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + r2TouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + upTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + downTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + leftTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + rightTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + l3TouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + r3TouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + oneFingerTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + twoFingerTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + optionsTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + shareTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + psTouchInvStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + advColorDialog - DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.85.0, Culture=neutral, PublicKeyToken=null + DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.87.0, Culture=neutral, PublicKeyToken=null Options diff --git a/DS4Windows/DS4Forms/SaveWhere.es.resx b/DS4Windows/DS4Forms/SaveWhere.es.resx index 2c6e092..d7702fe 100644 --- a/DS4Windows/DS4Forms/SaveWhere.es.resx +++ b/DS4Windows/DS4Forms/SaveWhere.es.resx @@ -127,7 +127,7 @@ No elimines los otros ajustes aún - Para aquellos que prefieren un programa portable Nota: esta opción no funciona si esta en una carpeta admin son o sin UAC + Para aquellos que prefieren un programa portable. Nota: esta opción no funciona si esta en una carpeta admin con o sin UAC Para aquellos que prefieren una instalación de ajustes regular se guarda en %appdata%/ds4tool diff --git a/DS4Windows/DS4Forms/SpecActions.es.resx b/DS4Windows/DS4Forms/SpecActions.es.resx index 37f5963..e1c2265 100644 --- a/DS4Windows/DS4Forms/SpecActions.es.resx +++ b/DS4Windows/DS4Forms/SpecActions.es.resx @@ -139,7 +139,7 @@ Grabar una macro - Lanzar un programa + Abrir un programa Cargar un perfil @@ -151,37 +151,37 @@ Comprobar batería - a través del barra de luz + Por medio de la barra de luz Escanear del código - via notificación + Por medio de notificación - Oprimiendo trigger unload + Presionar gatillo de descarga - Soltando el trigger unload + Soltar gatillo de descarga Gatillo - Liberar Gatillo + Soltar Gatillo Argumentos - Oprimir el gatillo doblemente + Presionar el gatillo doblemente - Dejar oprimido el gatillo + Dejar presionado el gatillo - Dejar oprimido por + Dejar presionado por Nombre @@ -190,9 +190,9 @@ segundos - Oprimir el gatillo + Presionar el gatillo - Desligar tecla por + Desactivar tecla por \ No newline at end of file diff --git a/DS4Windows/DS4Forms/WelcomeDialog.es.resx b/DS4Windows/DS4Forms/WelcomeDialog.es.resx index 8562bf7..b0d80d6 100644 --- a/DS4Windows/DS4Forms/WelcomeDialog.es.resx +++ b/DS4Windows/DS4Forms/WelcomeDialog.es.resx @@ -121,20 +121,20 @@ Paso 1: Instalar el Driver DS4 - Paso 2: Si usas Windows 7 o inferior, instala el Driver 360 + Paso 2: Si usas Windows 7 o inferior, instala el Driver de Xbox 360 135, 13 - Configuracion de Bluetooth + Configuración del Bluetooth Si esta ventana reaparece despues de instalar, necesitas reiniciar tu PC o esperar 10-15 minutos a que Windows reconozca el driver - Si usas un Controlador X360 en esta PC, puedes omitir esto + Si usas un Controlador de Xbox 360 en esta PC, puedes omitir esto Finalizado @@ -143,12 +143,12 @@ Bienvenido a DS4Windows - Para configurar el bluetooth (opcional): Mantenga presionado el botón PS y Share durante 3 segundos. La luz del controlador comenzará a parpadear. + Para configurar el bluetooth (opcional): Mantenga presionado el botón PS y Share durante 3 segundos. La luz del control comenzará a parpadear. - Paso 3: Para conectar el control DS4 por medio de cable usb sólo debe conectar el cable microusb en el DS4 y el usb común en la PC. + Paso 3: Para conectar el control DS4 por medio de un cable USB sólo debe conectar el cable micro USB en el DS4 y el USB común en la PC. - Una vez que esté parpadeando, vaya a Configuración de Bluetooth y conéctese al "Wireless Controller". Si le pide un código de emparejamiento, utilice el "0000". Una vez emparejado, el controlador estará listo. ¡A divertirse! + Una vez que esté parpadeando, vaya a Configuración del Bluetooth y conéctese al "Wireless Controller". Si le pide un código de emparejamiento, utilice el "0000". Una vez emparejado, el control estará listo. ¡A divertirse! \ No newline at end of file diff --git a/DS4Windows/DS4Forms/WinProgs.cs b/DS4Windows/DS4Forms/WinProgs.cs index 9d19a14..232ed85 100644 --- a/DS4Windows/DS4Forms/WinProgs.cs +++ b/DS4Windows/DS4Forms/WinProgs.cs @@ -1,20 +1,12 @@ -using Microsoft.Win32; -using System; +using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Linq; using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using System.IO; -using System.Net; -using System.Text.RegularExpressions; using System.Xml; using System.Runtime.InteropServices; -//using Ookii.Dialogs; namespace DS4Windows { @@ -43,8 +35,10 @@ namespace DS4Windows cbs[i].Items.Add(Properties.Resources.noneProfile); cbs[i].SelectedIndex = cbs[i].Items.Count - 1; } + if (!File.Exists(Global.appdatapath + @"\Auto Profiles.xml")) Create(); + LoadP(); if (Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common")) @@ -64,7 +58,7 @@ namespace DS4Windows public bool Create() { - Boolean Saved = true; + bool Saved = true; try { @@ -101,10 +95,13 @@ namespace DS4Windows programpaths.Clear(); if (!File.Exists(Global.appdatapath + "\\Auto Profiles.xml")) return; + doc.Load(Global.appdatapath + "\\Auto Profiles.xml"); XmlNodeList programslist = doc.SelectNodes("Programs/Program"); foreach (XmlNode x in programslist) programpaths.Add(x.Attributes["path"].Value); + + lVPrograms.BeginUpdate(); foreach (string st in programpaths) { if (File.Exists(st)) @@ -125,15 +122,9 @@ namespace DS4Windows RemoveP(st, false, false); } } + lVPrograms.EndUpdate(); } - - private void bnLoadSteam_Click(object sender, EventArgs e) - { - - } - - private void GetApps(string path) { lodsf.Clear(); @@ -147,6 +138,7 @@ namespace DS4Windows } catch { } } + appsloaded = true; } @@ -162,8 +154,10 @@ namespace DS4Windows } catch { } } + return lods; } + private void GetShortcuts(string path) { lodsf.Clear(); @@ -171,22 +165,32 @@ namespace DS4Windows lodsf.AddRange(Directory.GetFiles(@"C:\ProgramData\Microsoft\Windows\Start Menu\Programs", "*.lnk", SearchOption.AllDirectories)); for (int i = 0; i < lodsf.Count; i++) lodsf[i] = GetTargetPath(lodsf[i]); + appsloaded = true; } - void appstimer_Tick(object sender, EventArgs e) + void addLoadedApps() { if (appsloaded) { bnAddPrograms.Text = Properties.Resources.AddingToList; for (int i = lodsf.Count - 1; i >= 0; i--) + { if (lodsf[i].Contains("etup") || lodsf[i].Contains("dotnet") || lodsf[i].Contains("SETUP") || lodsf[i].Contains("edist") || lodsf[i].Contains("nstall") || String.IsNullOrEmpty(lodsf[i])) lodsf.RemoveAt(i); + } + for (int i = lodsf.Count - 1; i >= 0; i--) + { for (int j = programpaths.Count - 1; j >= 0; j--) + { if (lodsf[i].ToLower().Replace('/', '\\') == programpaths[j].ToLower().Replace('/', '\\')) lodsf.RemoveAt(i); + } + } + + lVPrograms.BeginUpdate(); foreach (string st in lodsf) { if (File.Exists(st)) @@ -199,14 +203,14 @@ namespace DS4Windows lVPrograms.Items.Add(lvi); } } + lVPrograms.EndUpdate(); + bnAddPrograms.Text = Properties.Resources.AddPrograms; bnAddPrograms.Enabled = true; appsloaded = false; - ((Timer)sender).Stop(); } } - public void Save(string name) { m_Xdoc.Load(m_Profile); @@ -226,16 +230,20 @@ namespace DS4Windows el.AppendChild(m_Xdoc.CreateElement("Controller3")).InnerText = cBProfile3.Text; el.AppendChild(m_Xdoc.CreateElement("Controller4")).InnerText = cBProfile4.Text; el.AppendChild(m_Xdoc.CreateElement("TurnOff")).InnerText = cBTurnOffDS4W.Checked.ToString(); + try { XmlNode oldxmlprocess = m_Xdoc.SelectSingleNode("/Programs/Program[@path=\"" + lBProgramPath.Text + "\"]"); Node.ReplaceChild(el, oldxmlprocess); } catch { Node.AppendChild(el); } + m_Xdoc.AppendChild(Node); m_Xdoc.Save(m_Profile); + if (lVPrograms.SelectedItems.Count > 0) lVPrograms.SelectedItems[0].Checked = true; + form.LoadP(); } @@ -251,7 +259,9 @@ namespace DS4Windows { Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]" + "/Controller" + (i + 1)); if (Item != null) + { for (int j = 0; j < cbs[i].Items.Count; j++) + { if (cbs[i].Items[j].ToString() == Item.InnerText) { cbs[i].SelectedIndex = j; @@ -260,9 +270,12 @@ namespace DS4Windows } else cbs[i].SelectedIndex = cbs[i].Items.Count - 1; + } + } else cbs[i].SelectedIndex = cbs[i].Items.Count - 1; } + Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]" + "/TurnOff"); bool turnOff; if (Item != null && bool.TryParse(Item.InnerText, out turnOff)) @@ -276,6 +289,7 @@ namespace DS4Windows { for (int i = 0; i < 4; i++) cbs[i].SelectedIndex = cbs[i].Items.Count - 1; + cBTurnOffDS4W.Checked = false; bnSave.Enabled = false; } @@ -283,22 +297,24 @@ namespace DS4Windows public void RemoveP(string name, bool uncheck, bool reload = true) { - XmlDocument doc = new XmlDocument(); doc.Load(m_Profile); XmlNode Node = doc.SelectSingleNode("Programs"); XmlNode Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]"); if (Item != null) Node.RemoveChild(Item); + doc.AppendChild(Node); doc.Save(m_Profile); if (lVPrograms.SelectedItems.Count > 0 && uncheck) lVPrograms.SelectedItems[0].Checked = false; + for (int i = 0; i < 4; i++) cbs[i].SelectedIndex = cbs[i].Items.Count - 1; + bnSave.Enabled = false; if (reload) - form.LoadP(); + form.LoadP(); } private void CBProfile_IndexChanged(object sender, EventArgs e) @@ -306,6 +322,7 @@ namespace DS4Windows int last = cbs[0].Items.Count - 1; if (lBProgramPath.Text != string.Empty) bnSave.Enabled = true; + if (cbs[0].SelectedIndex == last && cbs[1].SelectedIndex == last && cbs[2].SelectedIndex == last && cbs[3].SelectedIndex == last && !cBTurnOffDS4W.Checked) bnSave.Enabled = false; @@ -315,6 +332,7 @@ namespace DS4Windows { if (lBProgramPath.Text != "") Save(lBProgramPath.Text); + bnSave.Enabled = false; } @@ -328,8 +346,10 @@ namespace DS4Windows if (lBProgramPath.Text != "") LoadP(lBProgramPath.Text); else + { for (int i = 0; i < 4; i++) cbs[i].SelectedIndex = cbs[i].Items.Count - 1; + } } private void bnDelete_Click(object sender, EventArgs e) @@ -359,41 +379,24 @@ namespace DS4Windows form.RefreshAutoProfilesPage(); } - - private void addSteamGamesToolStripMenuItem_Click(object sender, EventArgs e) + private async void addSteamGamesToolStripMenuItem_Click(object sender, EventArgs e) { - try - { - var AppCollectionThread = new System.Threading.Thread(() => GetApps(steamgamesdir)); - AppCollectionThread.IsBackground = true; - AppCollectionThread.Start(); - } - catch { } bnAddPrograms.Text = Properties.Resources.Loading; bnAddPrograms.Enabled = false; cMSPrograms.Items.Remove(addSteamGamesToolStripMenuItem); - Timer appstimer = new Timer(); - appstimer.Start(); - appstimer.Tick += appstimer_Tick; + await System.Threading.Tasks.Task.Run(() => GetApps(steamgamesdir)); + addLoadedApps(); } - private void addDirectoryToolStripMenuItem_Click(object sender, EventArgs e) + private async void addDirectoryToolStripMenuItem_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { - try - { - var AppCollectionThread = new System.Threading.Thread(() => GetApps(fbd.SelectedPath)); - AppCollectionThread.IsBackground = true; - AppCollectionThread.Start(); - } - catch { } bnAddPrograms.Text = Properties.Resources.Loading; bnAddPrograms.Enabled = false; - Timer appstimer = new Timer(); - appstimer.Start(); - appstimer.Tick += appstimer_Tick; + await System.Threading.Tasks.Task.Run(() => GetApps(fbd.SelectedPath)); + addLoadedApps(); } } @@ -406,6 +409,7 @@ namespace DS4Windows { file = GetTargetPath(file); } + lBProgramPath.Text = file; iLIcons.Images.Add(Icon.ExtractAssociatedIcon(file)); ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(file), lVPrograms.Items.Count); @@ -414,39 +418,22 @@ namespace DS4Windows } } - private void addOriginGamesToolStripMenuItem_Click(object sender, EventArgs e) + private async void addOriginGamesToolStripMenuItem_Click(object sender, EventArgs e) { - try - { - var AppCollectionThread = new System.Threading.Thread(() => GetApps(origingamesdir)); - AppCollectionThread.IsBackground = true; - AppCollectionThread.Start(); - } - catch { } bnAddPrograms.Text = Properties.Resources.Loading; bnAddPrograms.Enabled = false; cMSPrograms.Items.Remove(addOriginGamesToolStripMenuItem); - Timer appstimer = new Timer(); - appstimer.Start(); - appstimer.Tick += appstimer_Tick; + await System.Threading.Tasks.Task.Run(() => GetApps(origingamesdir)); + addLoadedApps(); } - private void addProgramsFromStartMenuToolStripMenuItem_Click(object sender, EventArgs e) + private async void addProgramsFromStartMenuToolStripMenuItem_Click(object sender, EventArgs e) { - //MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs"); - try - { - var AppCollectionThread = new System.Threading.Thread(() => GetShortcuts(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs")); - AppCollectionThread.IsBackground = true; - AppCollectionThread.Start(); - } - catch { } bnAddPrograms.Text = Properties.Resources.Loading; bnAddPrograms.Enabled = false; cMSPrograms.Items.Remove(addProgramsFromStartMenuToolStripMenuItem); - Timer appstimer = new Timer(); - appstimer.Start(); - appstimer.Tick += appstimer_Tick; + await System.Threading.Tasks.Task.Run(() => GetShortcuts(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs")); + addLoadedApps(); } public static string GetTargetPath(string filePath) @@ -545,6 +532,7 @@ namespace DS4Windows } } } + class NativeMethods2 { [DllImport("msi.dll", CharSet = CharSet.Auto)] diff --git a/DS4Windows/DS4Forms/WinProgs.es.resx b/DS4Windows/DS4Forms/WinProgs.es.resx index 313df40..4ab1ed9 100644 --- a/DS4Windows/DS4Forms/WinProgs.es.resx +++ b/DS4Windows/DS4Forms/WinProgs.es.resx @@ -128,25 +128,25 @@ 70, 13 - Controlador 1 + Control 1 70, 13 - Controlador 2 + Control 2 70, 13 - Controlador 3 + Control 3 70, 13 - Controlador 4 + Control 4 Quitar diff --git a/DS4Windows/DS4Library/DS4Audio.cs b/DS4Windows/DS4Library/DS4Audio.cs index b256870..c3fb325 100644 --- a/DS4Windows/DS4Library/DS4Audio.cs +++ b/DS4Windows/DS4Library/DS4Audio.cs @@ -56,6 +56,18 @@ namespace DS4Windows.DS4Library Marshal.ThrowExceptionForHR(audioDevice.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out interfacePointer)); endpointVolume = interfacePointer as IAudioEndpointVolume; } + else if (deviceName.Contains("Headset Earphone (Wireless Controller)")) + { + object interfacePointer; + Marshal.ThrowExceptionForHR(audioDevice.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out interfacePointer)); + endpointVolume = interfacePointer as IAudioEndpointVolume; + } + else if (deviceName.Contains("Headset Microphone (Wireless Controller)")) + { + object interfacePointer; + Marshal.ThrowExceptionForHR(audioDevice.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out interfacePointer)); + endpointVolume = interfacePointer as IAudioEndpointVolume; + } Marshal.ReleaseComObject(audioDevice); } diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index abcbf64..93cc0c4 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -112,18 +112,18 @@ namespace DS4Windows public class DS4Device { - private const int BT_OUTPUT_REPORT_LENGTH = 78; - private const int BT_INPUT_REPORT_LENGTH = 547; + internal const int BT_OUTPUT_REPORT_LENGTH = 78; + internal const int BT_INPUT_REPORT_LENGTH = 547; // Use large value for worst case scenario - private const int READ_STREAM_TIMEOUT = 1000; + internal const int READ_STREAM_TIMEOUT = 3000; // Isolated BT report can have latency as high as 15 ms // due to hardware. - private const int WARN_INTERVAL_BT = 20; - private const int WARN_INTERVAL_USB = 10; + internal const int WARN_INTERVAL_BT = 20; + internal const int WARN_INTERVAL_USB = 10; // Maximum values for battery level when no USB cable is connected // and when a USB cable is connected - private const int BATTERY_MAX = 8; - private const int BATTERY_MAX_USB = 11; + internal const int BATTERY_MAX = 8; + internal const int BATTERY_MAX_USB = 11; public const string blankSerial = "00:00:00:00:00:00"; private HidDevice hDevice; private string Mac; @@ -407,7 +407,7 @@ namespace DS4Windows private bool timeoutEvent = false; public DS4Device(HidDevice hidDevice) - { + { hDevice = hidDevice; conType = HidConnectionType(hDevice); Mac = hDevice.readSerial(); @@ -419,6 +419,13 @@ namespace DS4Windows if (conType == ConnectionType.USB) { warnInterval = WARN_INTERVAL_USB; + HidDeviceAttributes tempAttr = hDevice.Attributes; + if (tempAttr.VendorId == 0x054C && tempAttr.ProductId == 0x09CC) + { + audio = new DS4Audio(); + micAudio = new DS4Audio(DS4Library.CoreAudio.DataFlow.Capture); + } + synced = true; } else @@ -441,6 +448,8 @@ namespace DS4Windows touchpad = new DS4Touchpad(); sixAxis = new DS4SixAxis(); + + refreshCalibration(); } private void timeoutTestThread() @@ -460,6 +469,14 @@ namespace DS4Windows } } + public void refreshCalibration() + { + byte[] calibration = new byte[41]; + calibration[0] = conType == ConnectionType.BT ? (byte)0x05 : (byte)0x02; + hDevice.readFeatureData(calibration); + sixAxis.setCalibrationData(ref calibration, conType == ConnectionType.USB); + } + public void StartUpdate() { if (ds4Input == null) @@ -483,6 +500,8 @@ namespace DS4Windows ds4Output.Start(); timeoutCheckThread = new Thread(timeoutTestThread); + timeoutCheckThread.Priority = ThreadPriority.BelowNormal; + timeoutCheckThread.Name = "DS4 Timeout thread: " + Mac; timeoutCheckThread.IsBackground = true; timeoutCheckThread.Start(); } @@ -559,53 +578,60 @@ namespace DS4Windows } } + private byte outputPendCount = 0; private void performDs4Output() { - lock (outputReport) + try { - try + int lastError = 0; + outputPendCount = 3; + while (!exitOutputThread) { - int lastError = 0; - while (!exitOutputThread) - { - bool result = false; - if (outputRumble) - { - result = writeOutput(); + bool result = false; - if (!result) - { - int thisError = Marshal.GetLastWin32Error(); - if (lastError != 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; - } - } - else - { - outputRumble = false; - } + if (outputRumble) + { + lock (outputReportBuffer) + { + outputReportBuffer.CopyTo(outputReport, 0); + outputRumble = false; + outputPendCount--; } - if (!outputRumble) + result = writeOutput(); + + if (!result) { - lastError = 0; - Monitor.Wait(outputReport); - /*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); - */ + outputRumble = true; + int thisError = Marshal.GetLastWin32Error(); + if (lastError != 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; + } } } - } - catch (ThreadInterruptedException) - { + if (!outputRumble) + { + lastError = 0; + lock (outputReportBuffer) + { + Monitor.Wait(outputReportBuffer); + } + + /*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); + */ + } } } + catch (ThreadInterruptedException) + { + } } /** Is the device alive and receiving valid sensor input reports? */ @@ -636,7 +662,7 @@ namespace DS4Windows public double Latency = 0.0; public string error; - public bool firstReport = false; + public bool firstReport = true; public bool oldCharging = false; double curTimeDouble = 0.0; double oldTimeDouble = 0.0; @@ -644,11 +670,15 @@ namespace DS4Windows bool ds4InactiveFrame = true; bool idleInput = true; + bool timeStampInit = false; + uint timeStampPrevious = 0; + uint deltaTimeCurrent = 0; + private void performDs4Input() { firstActive = DateTime.UtcNow; NativeMethods.HidD_SetNumInputBuffers(hDevice.safeReadHandle.DangerousGetHandle(), 2); - Queue latencyQueue = new Queue(51); // Set capacity at max + 1 to avoid any resizing + Queue latencyQueue = new Queue(31); // Set capacity at max + 1 to avoid any resizing int tempLatencyCount = 0; long oldtime = 0; string currerror = string.Empty; @@ -658,16 +688,20 @@ namespace DS4Windows timeoutEvent = false; ds4InactiveFrame = true; idleInput = true; + bool syncWriteReport = true; int maxBatteryValue = 0; int tempBattery = 0; + uint tempStamp = 0; + double elapsedDeltaTime = 0.0; + uint tempDelta = 0; while (!exitInputThread) { oldCharging = charging; currerror = string.Empty; - if (tempLatencyCount >= 50) + if (tempLatencyCount >= 30) { latencyQueue.Dequeue(); tempLatencyCount--; @@ -809,21 +843,17 @@ namespace DS4Windows cState.TouchButton = (inputReport[7] & 0x02) != 0; cState.FrameCounter = (byte)(inputReport[7] >> 2); - try + charging = (inputReport[30] & 0x10) != 0; + maxBatteryValue = charging ? BATTERY_MAX_USB : BATTERY_MAX; + tempBattery = (inputReport[30] & 0x0f) * 100 / maxBatteryValue; + battery = Math.Min((byte)tempBattery, (byte)100); + cState.Battery = (byte)battery; + //System.Diagnostics.Debug.WriteLine("CURRENT BATTERY: " + (inputReport[30] & 0x0f) + " | " + tempBattery + " | " + battery); + if (inputReport[30] != priorInputReport30) { - charging = (inputReport[30] & 0x10) != 0; - maxBatteryValue = charging ? BATTERY_MAX_USB : BATTERY_MAX; - tempBattery = (inputReport[30] & 0x0f) * 100 / maxBatteryValue; - battery = Math.Min((byte)tempBattery, (byte)100); - cState.Battery = (byte)battery; - //System.Diagnostics.Debug.WriteLine("CURRENT BATTERY: " + (inputReport[30] & 0x0f) + " | " + tempBattery + " | " + battery); - if (inputReport[30] != priorInputReport30) - { - priorInputReport30 = inputReport[30]; - //Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> power subsystem octet: 0x" + inputReport[30].ToString("x02")); - } + priorInputReport30 = inputReport[30]; + //Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> power subsystem octet: 0x" + inputReport[30].ToString("x02")); } - catch { currerror = "Index out of bounds: battery"; } // XXX DS4State mapping needs fixup, turn touches into an array[4] of structs. And include the touchpad details there instead. try @@ -840,18 +870,40 @@ namespace DS4Windows cState.Touch2Identifier = (byte)(inputReport[4 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] & 0x7f); cState.Touch1Finger = cState.Touch1 || cState.Touch2; // >= 1 touch detected cState.Touch2Fingers = cState.Touch1 && cState.Touch2; // 2 touches detected - 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; + int touchX = (((inputReport[2 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] & 0xF) << 8) | inputReport[1 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset]); + cState.TouchLeft = touchX >= 1920 * 2 / 5 ? false : true; + cState.TouchRight = touchX < 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); } } catch { currerror = "Index out of bounds: touchpad"; } + tempStamp = (uint)((ushort)(inputReport[11] << 8) | inputReport[10]); + if (timeStampInit == false) + { + timeStampInit = true; + deltaTimeCurrent = tempStamp * 16u / 3u; + } + else if (timeStampPrevious > tempStamp) + { + tempDelta = ushort.MaxValue - timeStampPrevious + tempStamp + 1u; + deltaTimeCurrent = tempDelta * 16u / 3u; + } + else + { + tempDelta = tempStamp - timeStampPrevious; + deltaTimeCurrent = tempDelta * 16u / 3u; + } + + cState.elapsedMicroSec = deltaTimeCurrent; + timeStampPrevious = tempStamp; + elapsedDeltaTime = 0.000001 * deltaTimeCurrent; // Convert from microseconds to seconds + // Store Gyro and Accel values Array.Copy(inputReport, 13, gyro, 0, 6); Array.Copy(inputReport, 19, accel, 0, 6); - sixAxis.handleSixaxis(gyro, accel, cState, lastTimeElapsedDouble); + sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime); /* Debug output of incoming HID data: if (cState.L2 == 0xff && cState.R2 == 0xff) @@ -948,7 +1000,6 @@ namespace DS4Windows if (Report != null) Report(this, EventArgs.Empty); - bool syncWriteReport = true; if (conType == ConnectionType.BT) { syncWriteReport = false; @@ -986,48 +1037,47 @@ namespace DS4Windows setTestRumble(); setHapticState(); - if (conType == ConnectionType.BT) - { - outputReportBuffer[0] = 0x11; - //outputReportBuffer[1] = 0x80; - //outputReportBuffer[1] = 0x84; - outputReportBuffer[1] = (byte)(0x80 | btPollRate); // input report rate - // enable rumble (0x01), lightbar (0x02), flash (0x04) - outputReportBuffer[3] = 0xf7; - outputReportBuffer[6] = rightLightFastRumble; // fast motor - outputReportBuffer[7] = leftHeavySlowRumble; // slow motor - outputReportBuffer[8] = ligtBarColor.red; // red - outputReportBuffer[9] = ligtBarColor.green; // green - outputReportBuffer[10] = ligtBarColor.blue; // blue - outputReportBuffer[11] = ledFlashOn; // flash on duration - outputReportBuffer[12] = ledFlashOff; // flash off duration - } - else - { - outputReportBuffer[0] = 0x05; - // enable rumble (0x01), lightbar (0x02), flash (0x04) - outputReportBuffer[1] = 0xf7; - outputReportBuffer[4] = rightLightFastRumble; // fast motor - outputReportBuffer[5] = leftHeavySlowRumble; // slow motor - outputReportBuffer[6] = ligtBarColor.red; // red - outputReportBuffer[7] = ligtBarColor.green; // green - outputReportBuffer[8] = ligtBarColor.blue; // blue - outputReportBuffer[9] = ledFlashOn; // flash on duration - outputReportBuffer[10] = ledFlashOff; // flash off duration - if (conType == ConnectionType.SONYWA) - { - // Headphone volume levels - outputReportBuffer[19] = outputReportBuffer[20] = - Convert.ToByte(audio.getVolume()); - // Microphone volume level - outputReportBuffer[21] = Convert.ToByte(micAudio.getVolume()); - } - } - bool quitOutputThread = false; - - lock (outputReport) + lock (outputReportBuffer) { + if (conType == ConnectionType.BT) + { + outputReportBuffer[0] = 0x11; + //outputReportBuffer[1] = 0x80; + //outputReportBuffer[1] = 0x84; + outputReportBuffer[1] = (byte)(0x80 | btPollRate); // input report rate + // enable rumble (0x01), lightbar (0x02), flash (0x04) + outputReportBuffer[3] = 0xf7; + outputReportBuffer[6] = rightLightFastRumble; // fast motor + outputReportBuffer[7] = leftHeavySlowRumble; // slow motor + outputReportBuffer[8] = ligtBarColor.red; // red + outputReportBuffer[9] = ligtBarColor.green; // green + outputReportBuffer[10] = ligtBarColor.blue; // blue + outputReportBuffer[11] = ledFlashOn; // flash on duration + outputReportBuffer[12] = ledFlashOff; // flash off duration + } + else + { + outputReportBuffer[0] = 0x05; + // enable rumble (0x01), lightbar (0x02), flash (0x04) + outputReportBuffer[1] = 0xf7; + outputReportBuffer[4] = rightLightFastRumble; // fast motor + outputReportBuffer[5] = leftHeavySlowRumble; // slow motor + outputReportBuffer[6] = ligtBarColor.red; // red + outputReportBuffer[7] = ligtBarColor.green; // green + outputReportBuffer[8] = ligtBarColor.blue; // blue + outputReportBuffer[9] = ledFlashOn; // flash on duration + outputReportBuffer[10] = ledFlashOff; // flash off duration + if (audio != null) + { + // Headphone volume levels + outputReportBuffer[19] = outputReportBuffer[20] = + Convert.ToByte(audio.getVolume()); + // Microphone volume level + outputReportBuffer[21] = Convert.ToByte(micAudio.getVolume()); + } + } + if (synchronous) { outputRumble = false; @@ -1049,15 +1099,19 @@ namespace DS4Windows } else { - bool output = false; + bool output = outputPendCount > 0; for (int i = 0, arlen = outputReport.Length; !output && i < arlen; i++) output = outputReport[i] != outputReportBuffer[i]; if (output) { + if (outputPendCount == 0) + { + outputPendCount = 3; + } + outputRumble = true; - outputReportBuffer.CopyTo(outputReport, 0); - Monitor.Pulse(outputReport); + Monitor.Pulse(outputReportBuffer); } } } @@ -1206,6 +1260,16 @@ namespace DS4Windows pState.CopyTo(state); } + public DS4State getCurrentStateRef() + { + return cState; + } + + public DS4State getPreviousStateRef() + { + return pState; + } + private bool isDS4Idle() { if (cState.Square || cState.Cross || cState.Circle || cState.Triangle) diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index 6e56838..49834f1 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -7,13 +7,37 @@ using System.Security.Principal; namespace DS4Windows { + public class VidPidInfo + { + public readonly int vid; + public readonly int pid; + internal VidPidInfo(int vid, int pid) + { + this.vid = vid; + this.pid = pid; + } + } + public class DS4Devices { + // (HID device path, DS4Device) private static Dictionary Devices = new Dictionary(); + private static HashSet deviceSerials = new HashSet(); private static HashSet DevicePaths = new HashSet(); // Keep instance of opened exclusive mode devices not in use (Charging while using BT connection) private static List DisabledDevices = new List(); + private static Stopwatch sw = new Stopwatch(); public static bool isExclusiveMode = false; + internal const int SONY_VID = 0x054C; + internal const int RAZER_VID = 0x1532; + internal const int NACON_VID = 0x146B; + + private static VidPidInfo[] knownDevices = + { + new VidPidInfo(SONY_VID, 0xBA0), new VidPidInfo(SONY_VID, 0x5C4), + new VidPidInfo(SONY_VID, 0x09CC), new VidPidInfo(RAZER_VID, 0x1000), + new VidPidInfo(NACON_VID, 0x0D01) + }; private static string devicePathToInstanceId(string devicePath) { @@ -34,9 +58,7 @@ namespace DS4Windows { lock (Devices) { - int[] vid = { 0x054C, 0x146B }; - int[] pid = { 0xBA0, 0x5C4, 0x09CC, 0x0D01 }; - IEnumerable hDevices = HidDevices.Enumerate(vid, pid); + IEnumerable hDevices = HidDevices.EnumerateDS4(knownDevices); // Sort Bluetooth first in case USB is also connected on the same controller. hDevices = hDevices.OrderBy((HidDevice d) => { return DS4Device.HidConnectionType(d); }); @@ -47,7 +69,7 @@ namespace DS4Windows string devicePlural = "device" + (devCount == 0 || devCount > 1 ? "s" : ""); //Log.LogToGui("Found " + devCount + " possible " + devicePlural + ". Examining " + devicePlural + ".", false); - for (int i = 0; i < devCount; i++) + for (int i = 0; i < devCount; i++) //foreach (HidDevice hDevice in hDevices) { HidDevice hDevice = tempList[i]; @@ -103,7 +125,7 @@ namespace DS4Windows { string serial = hDevice.readSerial(); bool validSerial = !serial.Equals(DS4Device.blankSerial); - if (Devices.ContainsKey(serial)) + if (validSerial && deviceSerials.Contains(serial)) { // happens when the BT endpoint already is open and the USB is plugged into the same host if (isExclusiveMode && hDevice.IsExclusive && @@ -121,29 +143,14 @@ namespace DS4Windows { DS4Device ds4Device = new DS4Device(hDevice); //ds4Device.Removal += On_Removal; - Devices.Add(ds4Device.MacAddress, ds4Device); + Devices.Add(hDevice.DevicePath, ds4Device); DevicePaths.Add(hDevice.DevicePath); + deviceSerials.Add(serial); } } } } } - - //allows to get DS4Device by specifying unique MAC address - //format for MAC address is XX:XX:XX:XX:XX:XX - public static DS4Device getDS4Controller(string mac) - { - lock (Devices) - { - DS4Device device = null; - try - { - Devices.TryGetValue(mac, out device); - } - catch (ArgumentNullException) { } - return device; - } - } // Returns DS4 controllers that were found and are running public static IEnumerable getDS4Controllers() @@ -172,6 +179,7 @@ namespace DS4Windows Devices.Clear(); DevicePaths.Clear(); + deviceSerials.Clear(); DisabledDevices.Clear(); } } @@ -185,8 +193,9 @@ namespace DS4Windows if (device != null) { device.HidDevice.CloseDevice(); - Devices.Remove(device.MacAddress); + Devices.Remove(device.HidDevice.DevicePath); DevicePaths.Remove(device.HidDevice.DevicePath); + deviceSerials.Remove(device.MacAddress); //purgeHiddenExclusiveDevices(); } } @@ -199,13 +208,19 @@ namespace DS4Windows DS4Device device = (DS4Device)sender; if (device != null) { + string devPath = device.HidDevice.DevicePath; string serial = device.getMacAddress(); - if (Devices.ContainsKey(serial)) + if (Devices.ContainsKey(devPath)) { - Devices.Remove(serial); + deviceSerials.Remove(serial); device.updateSerial(); serial = device.getMacAddress(); - Devices.Add(serial, device); + if (DS4Device.isValidSerial(serial)) + { + deviceSerials.Add(serial); + } + + device.refreshCalibration(); } } } @@ -252,7 +267,6 @@ namespace DS4Windows public static void reEnableDevice(string deviceInstanceId) { - Stopwatch sw = new Stopwatch(); bool success; Guid hidGuid = new Guid(); NativeMethods.HidD_GetHidGuid(ref hidGuid); @@ -287,7 +301,8 @@ namespace DS4Windows throw new Exception("Error disabling device, error code = " + Marshal.GetLastWin32Error()); } - sw.Start(); + //System.Threading.Thread.Sleep(50); + sw.Restart(); while (sw.ElapsedMilliseconds < 50) { // Use SpinWait to keep control of current thread. Using Sleep could potentially diff --git a/DS4Windows/DS4Library/DS4Sixaxis.cs b/DS4Windows/DS4Library/DS4Sixaxis.cs index b9093a3..15b4135 100644 --- a/DS4Windows/DS4Library/DS4Sixaxis.cs +++ b/DS4Windows/DS4Library/DS4Sixaxis.cs @@ -15,47 +15,210 @@ namespace DS4Windows public class SixAxis { + public const int ACC_RES_PER_G = 8192; + private const float F_ACC_RES_PER_G = ACC_RES_PER_G; + public const int GYRO_RES_IN_DEG_SEC = 16; + private const float F_GYRO_RES_IN_DEG_SEC = GYRO_RES_IN_DEG_SEC; + public int gyroYaw, gyroPitch, gyroRoll, accelX, accelY, accelZ; - public readonly int gyroYawFull, gyroPitchFull, gyroRollFull; + public int outputAccelX, outputAccelY, outputAccelZ; + public double accelXG, accelYG, accelZG; + public double angVelYaw, angVelPitch, angVelRoll; + public int gyroYawFull, gyroPitchFull, gyroRollFull; public int accelXFull, accelYFull, accelZFull; - public readonly byte touchID; - public readonly double elapsed; - public readonly SixAxis previousAxis = null; - public SixAxis(int X, int Y, int Z, int aX, int aY, int aZ, - double milliseconds, SixAxis prevAxis = null) + public double elapsed; + public SixAxis previousAxis = null; + + private double tempDouble = 0d; + + public SixAxis(int X, int Y, int Z, + int aX, int aY, int aZ, + double elapsedDelta, SixAxis prevAxis = null) + { + populate(X, Y, Z, aX, aY, aZ, elapsedDelta, prevAxis); + } + + public void copy(SixAxis src) + { + gyroYaw = src.gyroYaw; + gyroPitch = src.gyroPitch; + gyroRoll = src.gyroRoll; + + gyroYawFull = src.gyroYawFull; + accelXFull = src.accelXFull; accelYFull = src.accelYFull; accelZFull = src.accelZFull; + + angVelYaw = src.angVelYaw; + angVelPitch = src.angVelPitch; + angVelRoll = src.angVelRoll; + + accelXG = src.accelXG; + accelYG = src.accelYG; + accelZG = src.accelZG; + + // Put accel ranges between 0 - 128 abs + accelX = src.accelX; + accelY = src.accelY; + accelZ = src.accelZ; + outputAccelX = accelX; + outputAccelY = accelY; + outputAccelZ = accelZ; + + elapsed = src.elapsed; + previousAxis = src.previousAxis; + } + + public void populate(int X, int Y, int Z, + int aX, int aY, int aZ, + double elapsedDelta, SixAxis prevAxis = null) { gyroYaw = -X / 256; gyroPitch = Y / 256; gyroRoll = -Z / 256; - gyroYawFull = -X; - gyroPitchFull = Y; - gyroRollFull = -Z; + + gyroYawFull = -X; gyroPitchFull = Y; gyroRollFull = -Z; + accelXFull = -aX; accelYFull = -aY; accelZFull = aZ; + + angVelYaw = gyroYawFull / F_GYRO_RES_IN_DEG_SEC; + angVelPitch = gyroPitchFull / F_GYRO_RES_IN_DEG_SEC; + angVelRoll = gyroRollFull / F_GYRO_RES_IN_DEG_SEC; + + accelXG = tempDouble = accelXFull / F_ACC_RES_PER_G; + accelYG = tempDouble = accelYFull / F_ACC_RES_PER_G; + accelZG = tempDouble = accelZFull / F_ACC_RES_PER_G; // Put accel ranges between 0 - 128 abs accelX = -aX / 64; accelY = -aY / 64; accelZ = aZ / 64; + outputAccelX = accelX; + outputAccelY = accelY; + outputAccelZ = accelZ; - accelXFull = -aX; - accelYFull = -aY; - accelZFull = aZ; - elapsed = milliseconds; - + elapsed = elapsedDelta; previousAxis = prevAxis; } } + internal class CalibData + { + public int bias; + public int sensNumer; + public int sensDenom; + public const int GyroPitchIdx = 0, GyroYawIdx = 1, GyroRollIdx = 2, + AccelXIdx = 3, AccelYIdx = 4, AccelZIdx = 5; + } + public class DS4SixAxis { public event EventHandler SixAccelMoved = null; + private SixAxis sPrev = null, now = null; + private CalibData[] calibrationData = new CalibData[6] { new CalibData(), new CalibData(), + new CalibData(), new CalibData(), new CalibData(), new CalibData() + }; - internal int lastGyroYaw, lastGyroPitch, lastGyroRoll, - lastAX, lastAY, lastAZ; + public DS4SixAxis() + { + sPrev = new SixAxis(0, 0, 0, 0, 0, 0, 0.0); + now = new SixAxis(0, 0, 0, 0, 0, 0, 0.0); + } - internal double lastMilliseconds; - internal byte[] previousPacket = new byte[8]; + int temInt = 0; + public void setCalibrationData(ref byte[] calibData, bool fromUSB) + { + int pitchPlus, pitchMinus, yawPlus, yawMinus, rollPlus, rollMinus, + accelXPlus, accelXMinus, accelYPlus, accelYMinus, accelZPlus, accelZMinus, + gyroSpeedPlus, gyroSpeedMinus; - public void handleSixaxis(byte[] gyro, byte[] accel, DS4State state, double milliseconds) + calibrationData[0].bias = (short)((ushort)(calibData[2] << 8) | calibData[1]); + calibrationData[1].bias = (short)((ushort)(calibData[4] << 8) | calibData[3]); + calibrationData[2].bias = (short)((ushort)(calibData[6] << 8) | calibData[5]); + + if (!fromUSB) + { + pitchPlus = temInt = (short)((ushort)(calibData[8] << 8) | calibData[7]); + yawPlus = temInt = (short)((ushort)(calibData[10] << 8) | calibData[9]); + rollPlus = temInt = (short)((ushort)(calibData[12] << 8) | calibData[11]); + pitchMinus = temInt = (short)((ushort)(calibData[14] << 8) | calibData[13]); + yawMinus = temInt = (short)((ushort)(calibData[16] << 8) | calibData[15]); + rollMinus = temInt = (short)((ushort)(calibData[18] << 8) | calibData[17]); + } + else + { + pitchPlus = temInt = (short)((ushort)(calibData[8] << 8) | calibData[7]); + pitchMinus = temInt = (short)((ushort)(calibData[10] << 8) | calibData[9]); + yawPlus = temInt = (short)((ushort)(calibData[12] << 8) | calibData[11]); + yawMinus = temInt = (short)((ushort)(calibData[14] << 8) | calibData[13]); + rollPlus = temInt = (short)((ushort)(calibData[16] << 8) | calibData[15]); + rollMinus = temInt = (short)((ushort)(calibData[18] << 8) | calibData[17]); + } + + gyroSpeedPlus = temInt = (short)((ushort)(calibData[20] << 8) | calibData[19]); + gyroSpeedMinus = temInt = (short)((ushort)(calibData[22] << 8) | calibData[21]); + accelXPlus = temInt = (short)((ushort)(calibData[24] << 8) | calibData[23]); + accelXMinus = temInt = (short)((ushort)(calibData[26] << 8) | calibData[25]); + + accelYPlus = temInt = (short)((ushort)(calibData[28] << 8) | calibData[27]); + accelYMinus = temInt = (short)((ushort)(calibData[30] << 8) | calibData[29]); + + accelZPlus = temInt = (short)((ushort)(calibData[32] << 8) | calibData[31]); + accelZMinus = temInt = (short)((ushort)(calibData[34] << 8) | calibData[33]); + + int gyroSpeed2x = temInt = (gyroSpeedPlus + gyroSpeedMinus); + calibrationData[0].sensNumer = gyroSpeed2x* SixAxis.GYRO_RES_IN_DEG_SEC; + calibrationData[0].sensDenom = pitchPlus - pitchMinus; + + calibrationData[1].sensNumer = gyroSpeed2x* SixAxis.GYRO_RES_IN_DEG_SEC; + calibrationData[1].sensDenom = yawPlus - yawMinus; + + calibrationData[2].sensNumer = gyroSpeed2x* SixAxis.GYRO_RES_IN_DEG_SEC; + calibrationData[2].sensDenom = rollPlus - rollMinus; + + int accelRange = temInt = accelXPlus - accelXMinus; + calibrationData[3].bias = accelXPlus - accelRange / 2; + calibrationData[3].sensNumer = 2 * SixAxis.ACC_RES_PER_G; + calibrationData[3].sensDenom = accelRange; + + accelRange = temInt = accelYPlus - accelYMinus; + calibrationData[4].bias = accelYPlus - accelRange / 2; + calibrationData[4].sensNumer = 2 * SixAxis.ACC_RES_PER_G; + calibrationData[4].sensDenom = accelRange; + + accelRange = temInt = accelZPlus - accelZMinus; + calibrationData[5].bias = accelZPlus - accelRange / 2; + calibrationData[5].sensNumer = 2 * SixAxis.ACC_RES_PER_G; + calibrationData[5].sensDenom = accelRange; + } + + private void applyCalibs(ref int yaw, ref int pitch, ref int roll, + ref int accelX, ref int accelY, ref int accelZ) + { + CalibData current = calibrationData[0]; + temInt = pitch - current.bias; + pitch = temInt = (int)(temInt * (current.sensNumer / (float)current.sensDenom)); + + current = calibrationData[1]; + temInt = yaw - current.bias; + yaw = temInt = (int)(temInt * (current.sensNumer / (float)current.sensDenom)); + + current = calibrationData[2]; + temInt = roll - current.bias; + roll = temInt = (int)(temInt * (current.sensNumer / (float)current.sensDenom)); + + current = calibrationData[3]; + temInt = accelX - current.bias; + accelX = temInt = (int)(temInt * (current.sensNumer / (float)current.sensDenom)); + + current = calibrationData[4]; + temInt = accelY - current.bias; + accelY = temInt = (int)(temInt * (current.sensNumer / (float)current.sensDenom)); + + current = calibrationData[5]; + temInt = accelZ - current.bias; + accelZ = temInt = (int)(temInt * (current.sensNumer / (float)current.sensDenom)); + } + + public void handleSixaxis(byte[] gyro, byte[] accel, DS4State state, + double elapsedDelta) { int currentYaw = (short)((ushort)(gyro[3] << 8) | gyro[2]); int currentPitch = (short)((ushort)(gyro[1] << 8) | gyro[0]); @@ -64,30 +227,21 @@ namespace DS4Windows int AccelY = (short)((ushort)(accel[3] << 8) | accel[2]); int AccelZ = (short)((ushort)(accel[5] << 8) | accel[4]); + applyCalibs(ref currentYaw, ref currentPitch, ref currentRoll, ref AccelX, ref AccelY, ref AccelZ); + SixAxisEventArgs args = null; if (AccelX != 0 || AccelY != 0 || AccelZ != 0) { if (SixAccelMoved != null) { - SixAxis sPrev = null, now = null; - sPrev = new SixAxis(lastGyroYaw, lastGyroPitch, lastGyroRoll, - lastAX, lastAY, lastAZ, lastMilliseconds); - - now = new SixAxis(currentYaw, currentPitch, currentRoll, - AccelX, AccelY, AccelZ, milliseconds, sPrev); + sPrev.copy(now); + now.populate(currentYaw, currentPitch, currentRoll, + AccelX, AccelY, AccelZ, elapsedDelta, sPrev); args = new SixAxisEventArgs(state.ReportTimeStamp, now); state.Motion = now; SixAccelMoved(this, args); } - - lastGyroYaw = currentYaw; - lastGyroPitch = currentPitch; - lastGyroRoll = currentRoll; - lastAX = AccelX; - lastAY = AccelY; - lastAZ = AccelZ; - lastMilliseconds = milliseconds; } } } diff --git a/DS4Windows/DS4Library/DS4State.cs b/DS4Windows/DS4Library/DS4State.cs index d7fb3de..70c987e 100644 --- a/DS4Windows/DS4Library/DS4State.cs +++ b/DS4Windows/DS4Library/DS4State.cs @@ -23,6 +23,7 @@ namespace DS4Windows public double LYUnit; public double RXUnit; public double RYUnit; + public uint elapsedMicroSec = 0; public SixAxis Motion = null; public static readonly int DEFAULT_AXISDIR_VALUE = 127; @@ -46,6 +47,7 @@ namespace DS4Windows LYUnit = 0.0; RXUnit = 0.0; RYUnit = 0.0; + elapsedMicroSec = 0; Motion = new SixAxis(0, 0, 0, 0, 0, 0, 0.0); } @@ -93,6 +95,7 @@ namespace DS4Windows LYUnit = state.LYUnit; RXUnit = state.RXUnit; RYUnit = state.RYUnit; + elapsedMicroSec = state.elapsedMicroSec; Motion = state.Motion; } @@ -145,6 +148,7 @@ namespace DS4Windows state.LYUnit = LYUnit; state.RXUnit = RXUnit; state.RYUnit = RYUnit; + state.elapsedMicroSec = elapsedMicroSec; state.Motion = Motion; } diff --git a/DS4Windows/DS4Library/DS4StateExposed.cs b/DS4Windows/DS4Library/DS4StateExposed.cs index 56361d4..7777dce 100644 --- a/DS4Windows/DS4Library/DS4StateExposed.cs +++ b/DS4Windows/DS4Library/DS4StateExposed.cs @@ -78,5 +78,23 @@ namespace DS4Windows { return _state.Motion.accelZ; } + + public int OutputAccelX { get { return _state.Motion.outputAccelX; } } + public int getOutputAccelX() + { + return _state.Motion.outputAccelX; + } + + public int OutputAccelY { get { return _state.Motion.outputAccelY; } } + public int getOutputAccelY() + { + return _state.Motion.outputAccelY; + } + + public int OutputAccelZ { get { return _state.Motion.outputAccelZ; } } + public int getOutputAccelZ() + { + return _state.Motion.outputAccelZ; + } } } diff --git a/DS4Windows/DS4Library/DS4Touchpad.cs b/DS4Windows/DS4Library/DS4Touchpad.cs index 21f673e..5d8f1ef 100644 --- a/DS4Windows/DS4Library/DS4Touchpad.cs +++ b/DS4Windows/DS4Library/DS4Touchpad.cs @@ -92,10 +92,10 @@ namespace DS4Windows byte touchID1 = (byte)(data[0 + 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 currentY1 = ((data[2 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0xF0) >> 4) + (data[3 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] * 16); - int currentX2 = data[5 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] + ((data[6 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0xF) * 255); - int currentY2 = ((data[6 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0xF0) >> 4) + (data[7 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] * 16); + int currentX1 = ((data[2 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0x0F) << 8) | data[1 + TOUCHPAD_DATA_OFFSET + touchPacketOffset]; + int currentY1 = (data[3 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] << 4) | ((data[2 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0xF0) >> 4); + int currentX2 = ((data[6 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0x0F) << 8) | data[5 + TOUCHPAD_DATA_OFFSET + touchPacketOffset]; + int currentY2 = (data[7 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] << 4) | ((data[6 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0xF0) >> 4); TouchpadEventArgs args; if (sensors.Touch1 || sensors.Touch2) diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index eb4c434..02567de 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -9,10 +9,25 @@ Properties DS4Windows DS4Windows - v4.5 + v4.5.2 512 true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -73,13 +88,33 @@ prompt MinimumRecommendedRules.ruleset + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + true + pdbonly + x86 + false + prompt + MinimumRecommendedRules.ruleset + true + - - ..\packages\TaskScheduler.2.5.23\lib\net40\JetBrains.Annotations.dll + + ..\packages\TaskScheduler.2.5.28\lib\net452\JetBrains.Annotations.dll True - - ..\packages\TaskScheduler.2.5.23\lib\net40\Microsoft.Win32.TaskScheduler.dll + + ..\packages\TaskScheduler.2.5.28\lib\net452\Microsoft.Win32.TaskScheduler.dll True @@ -87,14 +122,10 @@ - - - - @@ -1149,8 +1180,33 @@ - + + + False + Microsoft .NET Framework 4.5.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + rem Copy compiled l18n assemblies to alt folder +GOTO END +if not exist $(TargetDir)Lang mkdir $(TargetDir)Lang +set langs=ar cs de de-DE el es fi fr fr-FR he hu id it it-IT ja ko nl pl ^ + +pt-BR ro-RO ru-RU sl sv tr uk vi zh-CN zh-Hans zh-Hant + +for %25%25l in (%25langs%25) do ( + xcopy $(TargetDir)%25%25l $(TargetDir)Lang\%25%25l\ /s /y +) + +:END +