Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

Commit

Permalink
Version 1.4.23
Browse files Browse the repository at this point in the history
Extended range needed for touchpad swipes actions to register
UI adjustments in profile settings, such as a color box for flashing
color, alignment adjustments, and the Sixaxis reading dot staying in
bounds of the box
Recording a macro for special actions now open up in a new window,
allowing for ctrl+tab to be used
When controller's latency passes 10ms, the log will show and the
controller will flash red until the latency is under 10ms
Hovering over the mac address shows the latency of said controller, if
it's connected via bluetooth
Option to choose when at low battery for the light to flash or pulse
Much cleaner/neater hotkeys/about window
Option to download language packs if your PC is not set to an english
language
Finished Italian Translations (Thanks again Giulio)
Finished German Translations (Thanks Ammonjak)
Updated Italian & Russian Translations
Reorganized the the code so all cs files are under the same project
  • Loading branch information
Jays2Kings committed Feb 8, 2015
1 parent 9fdaaad commit 7d7d5d7
Show file tree
Hide file tree
Showing 238 changed files with 20,303 additions and 22,230 deletions.
125 changes: 78 additions & 47 deletions DS4Control/Control.cs → DS4Control/ControlSerivce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DS4Library;

using System.IO;
using System.Reflection;
using System.Media;
namespace DS4Control
using System.Threading.Tasks;
namespace DS4Windows
{
public class Control
public class ControlService
{
public X360Device x360Bus;
public DS4Device[] DS4Controllers = new DS4Device[4];
Expand Down Expand Up @@ -36,7 +37,7 @@ private class X360Data
}
private X360Data[] processingData = new X360Data[4];

public Control()
public ControlService()
{
sp.Stream = Properties.Resources.EE;
x360Bus = new X360Device();
Expand Down Expand Up @@ -101,7 +102,7 @@ public bool Start(bool showlog = true)
{
if (showlog)
LogDebug(Properties.Resources.Starting);
DS4Devices.isExclusiveMode = Global.getUseExclusiveMode();
DS4Devices.isExclusiveMode = Global.UseExclusiveMode;
if (showlog)
{
LogDebug(Properties.Resources.SearchingController);
Expand All @@ -123,25 +124,25 @@ public bool Start(bool showlog = true)
device.Removal += this.On_DS4Removal;
device.Removal += DS4Devices.On_Removal;
touchPad[ind] = new Mouse(ind, device);
DS4Color color = Global.loadColor(ind);
device.LightBarColor = color;
if (!Global.getDinputOnly(ind))
device.LightBarColor = Global.MainColor[ind];
if (!Global.DinputOnly[ind])
x360Bus.Plugin(ind);
device.Report += this.On_Report;
TouchPadOn(ind, device);
string filename = Path.GetFileName(Global.getAProfile(ind));
//string filename = Global.ProfilePath[ind];
ind++;
if (showlog)
if (System.IO.File.Exists(Global.appdatapath + "\\Profiles\\" + filename))
if (System.IO.File.Exists(Global.appdatapath + "\\Profiles\\" + Global.ProfilePath[ind-1] + ".xml"))
{
string prolog = Properties.Resources.UsingProfile.Replace("*number*", ind.ToString()).Replace("*Profile name*", filename.Substring(0, filename.Length - 4));
string prolog = Properties.Resources.UsingProfile.Replace("*number*", ind.ToString()).Replace("*Profile name*", Global.ProfilePath[ind-1]);
LogDebug(prolog);
Log.LogToTray(prolog);
}
else
{
LogDebug("Controller " + ind + " is not using a profile");
Log.LogToTray("Controller " + ind + " is not using a profile");
string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (ind).ToString());
LogDebug(prolog);
Log.LogToTray(prolog);
}
if (ind >= 4) // out of Xinput devices!
break;
Expand Down Expand Up @@ -170,10 +171,12 @@ public bool Stop(bool showlog = true)
{
if (DS4Controllers[i] != null)
{
if (Global.getDCBTatStop() && !DS4Controllers[i].Charging && showlog)
if (Global.DCBTatStop && !DS4Controllers[i].Charging && showlog)
DS4Controllers[i].DisconnectBT();
else
{
DS4LightBar.forcelight[i] = false;
DS4LightBar.forcedFlash[i] = 0;
DS4LightBar.defualtLight = true;
DS4LightBar.updateLightBar(DS4Controllers[i], i, CurrentState[i], ExposedState[i], touchPad[i]);
System.Threading.Thread.Sleep(50);
Expand Down Expand Up @@ -227,22 +230,23 @@ public bool HotPlug()
device.Removal += this.On_DS4Removal;
device.Removal += DS4Devices.On_Removal;
touchPad[Index] = new Mouse(Index, device);
device.LightBarColor = Global.loadColor(Index);
device.LightBarColor = Global.MainColor[Index];
device.Report += this.On_Report;
if (!Global.getDinputOnly(Index))
if (!Global.DinputOnly[Index])
x360Bus.Plugin(Index);
TouchPadOn(Index, device);
string filename = Path.GetFileName(Global.getAProfile(Index));
if (System.IO.File.Exists(Global.appdatapath + "\\Profiles\\" + filename))
//string filename = Path.GetFileName(Global.ProfilePath[Index]);
if (System.IO.File.Exists(Global.appdatapath + "\\Profiles\\" + Global.ProfilePath[Index] + ".xml"))
{
string prolog = Properties.Resources.UsingProfile.Replace("*number*", (Index + 1).ToString()).Replace("*Profile name*", filename.Substring(0, filename.Length - 4));
string prolog = Properties.Resources.UsingProfile.Replace("*number*", (Index + 1).ToString()).Replace("*Profile name*", Global.ProfilePath[Index]);
LogDebug(prolog);
Log.LogToTray(prolog);
}
else
{
LogDebug("Controller " + (Index + 1) + " is not using a profile");
Log.LogToTray("Controller " + (Index + 1) + " is not using a profile");
string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (Index + 1).ToString());
LogDebug(prolog);
Log.LogToTray(prolog);
}

break;
Expand Down Expand Up @@ -428,7 +432,7 @@ protected virtual void On_DS4Removal(object sender, EventArgs e)
Global.ControllerStatusChanged(this);
}
}

public bool[] lag = { false, false, false, false };
//Called every time the new input report has arrived
protected virtual void On_Report(object sender, EventArgs e)
{
Expand All @@ -442,12 +446,19 @@ protected virtual void On_Report(object sender, EventArgs e)

if (ind != -1)
{
if (Global.getFlushHIDQueue(ind))
if (Global.FlushHIDQueue[ind])
device.FlushHID();
if (!string.IsNullOrEmpty(device.error))
{
LogDebug(device.error);
}
if (DateTime.UtcNow - device.firstActive > TimeSpan.FromSeconds(5))
{
if (device.Latency >= 10 && !lag[ind])
LagFlashWarning(ind, true);
else if (device.Latency < 10 && lag[ind])
LagFlashWarning(ind, false);
}
device.getExposedState(ExposedState[ind], CurrentState[ind]);
DS4State cState = CurrentState[ind];
device.getPreviousState(PreviousState[ind]);
Expand All @@ -458,11 +469,11 @@ protected virtual void On_Report(object sender, EventArgs e)
if (eastertime)
EasterTime(ind);
GetInputkeys(ind);
if (Global.getLSCurve(ind) + Global.getRSCurve(ind) + Global.getLSDeadzone(ind) + Global.getRSDeadzone(ind) +
Global.getL2Deadzone(ind) + Global.getR2Deadzone(ind) > 0) //if a curve or deadzone is in place
if (Global.LSCurve[ind] + Global.RSCurve[ind] + Global.LSDeadzone[ind] + Global.RSDeadzone[ind] +
Global.L2Deadzone[ind] + Global.R2Deadzone[ind] > 0) //if a curve or deadzone is in place
cState = Mapping.SetCurveAndDeadzone(ind, cState);
if (!recordingMacro && (!string.IsNullOrEmpty(Global.tempprofilename[ind]) ||
Global.getHasCustomKeysorButtons(ind) || Global.getHasShiftCustomKeysorButtons(ind) || Global.GetProfileActions(ind).Count > 0))
Global.getHasCustomKeysorButtons(ind) || Global.getHasShiftCustomKeysorButtons(ind) || Global.ProfileActions[ind].Count > 0))
{
Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind], touchPad[ind], this);
cState = MappedState[ind];
Expand Down Expand Up @@ -490,10 +501,30 @@ protected virtual void On_Report(object sender, EventArgs e)
// Output any synthetic events.
Mapping.Commit(ind);
// Pull settings updates.
device.IdleTimeout = Global.getIdleDisconnectTimeout(ind);
device.IdleTimeout = Global.IdleDisconnectTimeout[ind];
}
}

public void LagFlashWarning(int ind, bool on)
{
if (on)
{
lag[ind] = true;
LogDebug(Properties.Resources.LatencyOverTen.Replace("*number*", (ind + 1).ToString()), true);
DS4Color color = new DS4Color { red = 50, green = 0, blue = 0 };
DS4LightBar.forcedColor[ind] = color;
DS4LightBar.forcedFlash[ind] = 2;
DS4LightBar.forcelight[ind] = true;
}
else
{
lag[ind] = false;
LogDebug(Properties.Resources.LatencyNotOverTen.Replace("*number*", (ind + 1).ToString()));
DS4LightBar.forcelight[ind] = false;
DS4LightBar.forcedFlash[ind] = 0;
}
}

private void DoExtras(int ind)
{
DS4State cState = CurrentState[ind];
Expand Down Expand Up @@ -534,8 +565,8 @@ private void DoExtras(int ind)
if (extras[7] == 1)
{
if (oldmouse[ind] == -1)
oldmouse[ind] = Global.getButtonMouseSensitivity(ind);
Global.setButtonMouseSensitivity(ind, extras[8]);
oldmouse[ind] = Global.ButtonMouseSensitivity[ind];
Global.ButtonMouseSensitivity[ind] = extras[8];
}
}
catch { }
Expand All @@ -545,7 +576,7 @@ private void DoExtras(int ind)
DS4LightBar.forcelight[ind] = false;
DS4LightBar.forcedFlash[ind] = 0;
//Console.WriteLine(p.Key + " is done");
Global.setButtonMouseSensitivity(ind, oldmouse[ind]);
Global.ButtonMouseSensitivity[ind] = oldmouse[ind];
oldmouse[ind] = -1;
setRumble(0, 0, ind);
held[ind] = false;
Expand Down Expand Up @@ -711,24 +742,24 @@ public DS4Controls GetInputkeysDS4(int ind)
public int[] oldscrollvalue = { 0, 0, 0, 0 };
protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State pState)
{
if (!Global.getUseTPforControls(deviceID) && cState.Touch1 && pState.PS)
if (!Global.UseTPforControls[deviceID] && cState.Touch1 && pState.PS)
{
if (Global.getTouchSensitivity(deviceID) > 0 && touchreleased[deviceID])
if (Global.TouchSensitivity[deviceID] > 0 && touchreleased[deviceID])
{
oldtouchvalue[deviceID] = Global.getTouchSensitivity(deviceID);
oldscrollvalue[deviceID] = Global.getScrollSensitivity(deviceID);
Global.setTouchSensitivity(deviceID, 0);
Global.setScrollSensitivity(deviceID, 0);
LogDebug(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Log.LogToTray(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
oldtouchvalue[deviceID] = Global.TouchSensitivity[deviceID];
oldscrollvalue[deviceID] = Global.ScrollSensitivity[deviceID];
Global.TouchSensitivity[deviceID] = 0;
Global.ScrollSensitivity[deviceID] = 0;
LogDebug(Global.TouchSensitivity[deviceID] > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Log.LogToTray(Global.TouchSensitivity[deviceID] > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
touchreleased[deviceID] = false;
}
else if (touchreleased[deviceID])
{
Global.setTouchSensitivity(deviceID, oldtouchvalue[deviceID]);
Global.setScrollSensitivity(deviceID, oldscrollvalue[deviceID]);
LogDebug(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Log.LogToTray(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Global.TouchSensitivity[deviceID] = oldtouchvalue[deviceID];
Global.ScrollSensitivity[deviceID] = oldscrollvalue[deviceID];
LogDebug(Global.TouchSensitivity[deviceID] > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Log.LogToTray(Global.TouchSensitivity[deviceID] > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
touchreleased[deviceID] = false;
}
}
Expand All @@ -740,10 +771,10 @@ public virtual void StartTPOff(int deviceID)
{
if (deviceID > 4)
{
oldtouchvalue[deviceID] = Global.getTouchSensitivity(deviceID);
oldscrollvalue[deviceID] = Global.getScrollSensitivity(deviceID);
Global.setTouchSensitivity(deviceID, 0);
Global.setScrollSensitivity(deviceID, 0);
oldtouchvalue[deviceID] = Global.TouchSensitivity[deviceID];
oldscrollvalue[deviceID] = Global.ScrollSensitivity[deviceID];
Global.TouchSensitivity[deviceID] = 0;
Global.ScrollSensitivity[deviceID] = 0;
}
}

Expand Down Expand Up @@ -790,7 +821,7 @@ public virtual void OnDebug(object sender, DebugEventArgs args)
//sets the rumble adjusted with rumble boost
public virtual void setRumble(byte heavyMotor, byte lightMotor, int deviceNum)
{
byte boost = Global.loadRumbleBoost(deviceNum);
byte boost = Global.RumbleBoost[deviceNum];
uint lightBoosted = ((uint)lightMotor * (uint)boost) / 100;
if (lightBoosted > 255)
lightBoosted = 255;
Expand Down
Loading

0 comments on commit 7d7d5d7

Please sign in to comment.