Skip to content

Commit

Permalink
Version 1.4.0.85
Browse files Browse the repository at this point in the history
Many fixes for shift modifier
  • Loading branch information
Jays2Kings committed Nov 1, 2014
1 parent c8632a9 commit 8acd9b7
Show file tree
Hide file tree
Showing 7 changed files with 6,915 additions and 6,837 deletions.
40 changes: 21 additions & 19 deletions DS4Control/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ public static int DS4ControltoInt(DS4Controls ctrl)
public static async void MapCustom(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp)
{
bool shift;
cState.CopyTo(MappedState);
SyntheticState deviceState = Mapping.deviceState[device];
switch (Global.getShiftModifier(device))
{
Expand Down Expand Up @@ -361,8 +360,10 @@ public static async void MapCustom(int device, DS4State cState, DS4State MappedS
case 26: shift = cState.Touch1; break;
default: shift = false; break;
}
cState.CopyTo(MappedState);
if (shift)
MapShiftCustom(device, cState, MappedState, eState, tp);
//else
foreach (KeyValuePair<DS4Controls, string> customKey in Global.getCustomMacros(device))
{
if (shift == false ||
Expand Down Expand Up @@ -782,7 +783,7 @@ public static async void MapCustom(int device, DS4State cState, DS4State MappedS

public static async void MapShiftCustom(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp)
{
cState.CopyTo(MappedState);
//cState.CopyTo(MappedState);
SyntheticState deviceState = Mapping.deviceState[device];
foreach (KeyValuePair<DS4Controls, string> customKey in Global.getShiftCustomMacros(device)) //with delays
{
Expand Down Expand Up @@ -955,6 +956,7 @@ public static async void MapShiftCustom(int device, DS4State cState, DS4State Ma
List<DS4Controls> RYP = new List<DS4Controls>();
foreach (KeyValuePair<DS4Controls, X360Controls> customButton in customButtons)
{
resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped
DS4KeyType keyType = Global.getShiftCustomKeyType(device, customButton.Key);
int keyvalue = 0;
switch (customButton.Value)
Expand All @@ -969,7 +971,6 @@ public static async void MapShiftCustom(int device, DS4State cState, DS4State Ma
{
if (getBoolMapping(customButton.Key, cState, eState, tp))
{
resetToDefaultValue(customButton.Key, MappedState);
if (!pressedonce[keyvalue])
{
deviceState.currentClicks.toggle = !deviceState.currentClicks.toggle;
Expand Down Expand Up @@ -1068,6 +1069,7 @@ public static async void MapShiftCustom(int device, DS4State cState, DS4State Ma
break;
}
}
Console.WriteLine(Cross.Count);
foreach (DS4Controls dc in Cross)
if (getBoolMapping(dc, cState, eState, tp))
MappedState.Cross = true;
Expand Down Expand Up @@ -1120,21 +1122,21 @@ public static async void MapShiftCustom(int device, DS4State cState, DS4State Ma
if (getBoolMapping(dc, cState, eState, tp))
MappedState.PS = true;

if (Global.getCustomButton(device, DS4Controls.LXNeg) == X360Controls.None)
if (Global.getShiftCustomButton(device, DS4Controls.LXNeg) == X360Controls.None)
LXN.Add(DS4Controls.LXNeg);
if (Global.getCustomButton(device, DS4Controls.LXPos) == X360Controls.None)
if (Global.getShiftCustomButton(device, DS4Controls.LXPos) == X360Controls.None)
LXP.Add(DS4Controls.LXPos);
if (Global.getCustomButton(device, DS4Controls.LYNeg) == X360Controls.None)
if (Global.getShiftCustomButton(device, DS4Controls.LYNeg) == X360Controls.None)
LYN.Add(DS4Controls.LYNeg);
if (Global.getCustomButton(device, DS4Controls.LYPos) == X360Controls.None)
if (Global.getShiftCustomButton(device, DS4Controls.LYPos) == X360Controls.None)
LYP.Add(DS4Controls.LYPos);
if (Global.getCustomButton(device, DS4Controls.RXNeg) == X360Controls.None)
if (Global.getShiftCustomButton(device, DS4Controls.RXNeg) == X360Controls.None)
RXN.Add(DS4Controls.RXNeg);
if (Global.getCustomButton(device, DS4Controls.RXPos) == X360Controls.None)
if (Global.getShiftCustomButton(device, DS4Controls.RXPos) == X360Controls.None)
RXP.Add(DS4Controls.RXPos);
if (Global.getCustomButton(device, DS4Controls.RYNeg) == X360Controls.None)
if (Global.getShiftCustomButton(device, DS4Controls.RYNeg) == X360Controls.None)
RYN.Add(DS4Controls.RYNeg);
if (Global.getCustomButton(device, DS4Controls.RYPos) == X360Controls.None)
if (Global.getShiftCustomButton(device, DS4Controls.RYPos) == X360Controls.None)
RYP.Add(DS4Controls.RYPos);
if (LXN.Count > 0 || LXP.Count > 0)
{
Expand Down Expand Up @@ -1356,10 +1358,10 @@ public static byte getByteMapping(int device, DS4Controls control, DS4State cSta
case DS4Controls.Square: return (byte)(cState.Square ? 255 : 0);
case DS4Controls.Triangle: return (byte)(cState.Triangle ? 255 : 0);
case DS4Controls.Circle: return (byte)(cState.Circle ? 255 : 0);
case DS4Controls.TouchLeft: return (byte)(tp.leftDown ? 255 : 0);
case DS4Controls.TouchRight: return (byte)(tp.rightDown ? 255 : 0);
case DS4Controls.TouchMulti: return (byte)(tp.multiDown ? 255 : 0);
case DS4Controls.TouchUpper: return (byte)(tp.upperDown ? 255 : 0);
case DS4Controls.TouchLeft: return (byte)(tp != null && tp.leftDown ? 255 : 0);
case DS4Controls.TouchRight: return (byte)(tp != null && tp.rightDown ? 255 : 0);
case DS4Controls.TouchMulti: return (byte)(tp != null && tp.multiDown ? 255 : 0);
case DS4Controls.TouchUpper: return (byte)(tp != null && tp.upperDown ? 255 : 0);
case DS4Controls.LXNeg: return (byte)cState.LX;
case DS4Controls.LYNeg: return (byte)cState.LY;
case DS4Controls.RXNeg: return (byte)cState.RX;
Expand Down Expand Up @@ -1444,10 +1446,10 @@ public static byte getXYAxisMapping(int device, DS4Controls control, DS4State cS
case DS4Controls.Square: return (byte)(cState.Square ? trueVal : falseVal);
case DS4Controls.Triangle: return (byte)(cState.Triangle ? trueVal : falseVal);
case DS4Controls.Circle: return (byte)(cState.Circle ? trueVal : falseVal);
case DS4Controls.TouchLeft: return (byte)(tp.leftDown ? trueVal : falseVal);
case DS4Controls.TouchRight: return (byte)(tp.rightDown ? trueVal : falseVal);
case DS4Controls.TouchMulti: return (byte)(tp.multiDown ? trueVal : falseVal);
case DS4Controls.TouchUpper: return (byte)(tp.upperDown ? trueVal : falseVal);
case DS4Controls.TouchLeft: return (byte)(tp != null && tp.leftDown ? trueVal : falseVal);
case DS4Controls.TouchRight: return (byte)(tp != null && tp.rightDown ? trueVal : falseVal);
case DS4Controls.TouchMulti: return (byte)(tp != null && tp.multiDown ? trueVal : falseVal);
case DS4Controls.TouchUpper: return (byte)(tp != null && tp.upperDown ? trueVal : falseVal);
case DS4Controls.L2: if (alt) return (byte)(127 + cState.L2 / 2); else return (byte)(127 - cState.L2 / 2);
case DS4Controls.R2: if (alt) return (byte)(127 + cState.R2 / 2); else return (byte)(127 - cState.R2 / 2);
case DS4Controls.GyroXPos: if (eState.GyroX > SXD * 7500)
Expand Down
78 changes: 78 additions & 0 deletions DS4Control/ScpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,45 @@ private DS4Controls getDS4ControlsByName(string key)
case "bnGyroZN": return DS4Controls.GyroZNeg;


case "bnShiftShare": return DS4Controls.Share;
case "bnShiftL3": return DS4Controls.L3;
case "bnShiftR3": return DS4Controls.R3;
case "bnShiftOptions": return DS4Controls.Options;
case "bnShiftUp": return DS4Controls.DpadUp;
case "bnShiftRight": return DS4Controls.DpadRight;
case "bnShiftDown": return DS4Controls.DpadDown;
case "bnShiftLeft": return DS4Controls.DpadLeft;

case "bnShiftL1": return DS4Controls.L1;
case "bnShiftR1": return DS4Controls.R1;
case "bnShiftTriangle": return DS4Controls.Triangle;
case "bnShiftCircle": return DS4Controls.Circle;
case "bnShiftCross": return DS4Controls.Cross;
case "bnShiftSquare": return DS4Controls.Square;

case "bnShiftPS": return DS4Controls.PS;
case "bnShiftLSLeft": return DS4Controls.LXNeg;
case "bnShiftLSUp": return DS4Controls.LYNeg;
case "bnShiftRSLeft": return DS4Controls.RXNeg;
case "bnShiftRSUp": return DS4Controls.RYNeg;

case "bnShiftLSRight": return DS4Controls.LXPos;
case "bnShiftLSDown": return DS4Controls.LYPos;
case "bnShiftRSRight": return DS4Controls.RXPos;
case "bnShiftRSDown": return DS4Controls.RYPos;
case "bnShiftL2": return DS4Controls.L2;
case "bnShiftR2": return DS4Controls.R2;

case "bnShiftTouchLeft": return DS4Controls.TouchLeft;
case "bnShiftTouchMulti": return DS4Controls.TouchMulti;
case "bnShiftTouchUpper": return DS4Controls.TouchUpper;
case "bnShiftTouchRight": return DS4Controls.TouchRight;
case "bnShiftGsyroXP": return DS4Controls.GyroXPos;
case "bnShiftGyroXN": return DS4Controls.GyroXNeg;
case "bnShiftGyroZP": return DS4Controls.GyroZPos;
case "bnShiftGyroZN": return DS4Controls.GyroZNeg;

//old name
case "sbnShare": return DS4Controls.Share;
case "sbnL3": return DS4Controls.L3;
case "sbnR3": return DS4Controls.R3;
Expand Down Expand Up @@ -1139,6 +1178,45 @@ private DS4Controls getDS4ControlsByName(string key)
case "sbnGyroXN": return DS4Controls.GyroXNeg;
case "sbnGyroZP": return DS4Controls.GyroZPos;
case "sbnGyroZN": return DS4Controls.GyroZNeg;
//end old name

case "bnHoldShare": return DS4Controls.Share;
case "bnHoldL3": return DS4Controls.L3;
case "bnHoldR3": return DS4Controls.R3;
case "bnHoldOptions": return DS4Controls.Options;
case "bnHoldUp": return DS4Controls.DpadUp;
case "bnHoldRight": return DS4Controls.DpadRight;
case "bnHoldDown": return DS4Controls.DpadDown;
case "bnHoldLeft": return DS4Controls.DpadLeft;

case "bnHoldL1": return DS4Controls.L1;
case "bnHoldR1": return DS4Controls.R1;
case "bnHoldTriangle": return DS4Controls.Triangle;
case "bnHoldCircle": return DS4Controls.Circle;
case "bnHoldCross": return DS4Controls.Cross;
case "bnHoldSquare": return DS4Controls.Square;

case "bnHoldPS": return DS4Controls.PS;
case "bnHoldLSLeft": return DS4Controls.LXNeg;
case "bnHoldLSUp": return DS4Controls.LYNeg;
case "bnHoldRSLeft": return DS4Controls.RXNeg;
case "bnHoldRSUp": return DS4Controls.RYNeg;

case "bnHoldLSRight": return DS4Controls.LXPos;
case "bnHoldLSDown": return DS4Controls.LYPos;
case "bnHoldRSRight": return DS4Controls.RXPos;
case "bnHoldRSDown": return DS4Controls.RYPos;
case "bnHoldL2": return DS4Controls.L2;
case "bnHoldR2": return DS4Controls.R2;

case "bnHoldTouchLeft": return DS4Controls.TouchLeft;
case "bnHoldTouchMulti": return DS4Controls.TouchMulti;
case "bnHoldTouchUpper": return DS4Controls.TouchUpper;
case "bnHoldTouchRight": return DS4Controls.TouchRight;
case "bnHoldGsyroXP": return DS4Controls.GyroXPos;
case "bnHoldGyroXN": return DS4Controls.GyroXNeg;
case "bnHoldGyroZP": return DS4Controls.GyroZPos;
case "bnHoldGyroZN": return DS4Controls.GyroZNeg;
}
return 0;
}
Expand Down
15 changes: 10 additions & 5 deletions DS4Tool/KBM360.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ public KBM360(DS4Control.Control bus_device, int deviceNum, Options ooo, Button
cbScanCode.Checked = button.Font.Bold;
//cBMacro.Checked = button.Font.Underline;
lBMacroOn.Visible = button.Font.Underline;
if (button.Name.StartsWith("bn"))
Text = Properties.Resources.SelectActionTitle.Replace("*action*", button.Name.Substring(2));
else if (button.Name.StartsWith("sbn"))
if (button.Name.StartsWith("bnHold"))
{
Text = Properties.Resources.SelectActionTitle.Replace("*action*", button.Name.Substring(3));
btnFallBack.Text = "Fall Back";
Text = Properties.Resources.SelectActionTitle.Replace("*action*", button.Name.Substring(6));
btnFallBack.Text = "Disable";
}
else if (button.Name.StartsWith("bnShift"))
{
Text = Properties.Resources.SelectActionTitle.Replace("*action*", button.Name.Substring(7));
btnFallBack.Text = "Fall Back";
}
else if (button.Name.StartsWith("bn"))
Text = Properties.Resources.SelectActionTitle.Replace("*action*", button.Name.Substring(2));
foreach (System.Windows.Forms.Control control in this.Controls)
if (control is Button)
((Button)control).Click += anybtn_Click;
Expand Down
Loading

0 comments on commit 8acd9b7

Please sign in to comment.