Tweak button mapping translation

This commit is contained in:
Travis Nickles 2017-04-09 10:14:44 -07:00
parent 0f705e667e
commit 4a6f2fc278

View File

@ -849,30 +849,61 @@ namespace DS4Windows
else if (actionType == DS4ControlSettings.ActionType.Button)
{
int keyvalue = 0;
bool isAnalog = dcs.control.ToString().Contains("LX") ||
dcs.control.ToString().Contains("RX") ||
dcs.control.ToString().Contains("LY") ||
dcs.control.ToString().Contains("LY") ||
dcs.control.ToString().Contains("R2") ||
dcs.control.ToString().Contains("L2") ||
dcs.control.ToString().Contains("Gyro");
switch (getX360ControlsByName(action.ToString()))
bool isAnalog = false;
if (dcs.control >= DS4Controls.LXNeg && dcs.control <= DS4Controls.RYPos)
{
isAnalog = true;
}
else if (dcs.control == DS4Controls.L2 || dcs.control == DS4Controls.R2)
{
isAnalog = true;
}
else if (dcs.control >= DS4Controls.GyroXPos && dcs.control <= DS4Controls.GyroZNeg)
{
isAnalog = true;
}
X360Controls xboxControl = getX360ControlsByName(action.ToString());
if (xboxControl >= X360Controls.X && xboxControl <= X360Controls.A)
{
switch (xboxControl)
{
case X360Controls.A: tempControlDict.Add(DS4Controls.Cross, dcs.control); break;
case X360Controls.B: tempControlDict.Add(DS4Controls.Circle, dcs.control); break;
case X360Controls.X: tempControlDict.Add(DS4Controls.Square, dcs.control); break;
case X360Controls.Y: tempControlDict.Add(DS4Controls.Triangle, dcs.control); break;
default: break;
}
}
else if (xboxControl >= X360Controls.LB && xboxControl <= X360Controls.RS)
{
switch (xboxControl)
{
case X360Controls.LB: tempControlDict.Add(DS4Controls.L1, dcs.control); break;
case X360Controls.LT: tempControlDict.Add(DS4Controls.L2, dcs.control); break;
case X360Controls.LS: tempControlDict.Add(DS4Controls.L3, dcs.control); break;
case X360Controls.RB: tempControlDict.Add(DS4Controls.R1, dcs.control); break;
case X360Controls.RT: tempControlDict.Add(DS4Controls.R2, dcs.control); break;
case X360Controls.RS: tempControlDict.Add(DS4Controls.R3, dcs.control); break;
default: break;
}
}
else if (xboxControl >= X360Controls.DpadUp && xboxControl <= X360Controls.DpadLeft)
{
switch (xboxControl)
{
case X360Controls.DpadUp: tempControlDict.Add(DS4Controls.DpadUp, dcs.control); break;
case X360Controls.DpadDown: tempControlDict.Add(DS4Controls.DpadDown, dcs.control); break;
case X360Controls.DpadLeft: tempControlDict.Add(DS4Controls.DpadLeft, dcs.control); break;
case X360Controls.DpadRight: tempControlDict.Add(DS4Controls.DpadRight, dcs.control); break;
case X360Controls.Start: tempControlDict.Add(DS4Controls.Options, dcs.control); break;
case X360Controls.Guide: tempControlDict.Add(DS4Controls.PS, dcs.control); break;
case X360Controls.Back: tempControlDict.Add(DS4Controls.Share, dcs.control); break;
default: break;
}
}
else if (xboxControl >= X360Controls.LXNeg && xboxControl <= X360Controls.RYPos)
{
switch (xboxControl)
{
case X360Controls.LXNeg: tempControlDict.Add(DS4Controls.LXNeg, dcs.control); break;
case X360Controls.LYNeg: tempControlDict.Add(DS4Controls.LYNeg, dcs.control); break;
case X360Controls.RXNeg: tempControlDict.Add(DS4Controls.RXNeg, dcs.control); break;
@ -881,8 +912,13 @@ namespace DS4Windows
case X360Controls.LYPos: tempControlDict.Add(DS4Controls.LYPos, dcs.control); break;
case X360Controls.RXPos: tempControlDict.Add(DS4Controls.RXPos, dcs.control); break;
case X360Controls.RYPos: tempControlDict.Add(DS4Controls.RYPos, dcs.control); break;
case X360Controls.LT: tempControlDict.Add(DS4Controls.L2, dcs.control); break;
case X360Controls.RT: tempControlDict.Add(DS4Controls.R2, dcs.control); break;
default: break;
}
}
else if (xboxControl >= X360Controls.LeftMouse && xboxControl <= X360Controls.WDOWN)
{
switch (xboxControl)
{
case X360Controls.LeftMouse:
keyvalue = 256;
if (getBoolMapping(device, dcs.control, cState, eState, tp))
@ -922,6 +958,13 @@ namespace DS4Windows
else
deviceState.currentClicks.wDownCount++;
break;
default: break;
}
}
else if (xboxControl >= X360Controls.MouseUp && xboxControl <= X360Controls.MouseRight)
{
switch (xboxControl)
{
case X360Controls.MouseUp:
if (MouseDeltaY == 0)
{
@ -950,7 +993,21 @@ namespace DS4Windows
MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
}
break;
default: break;
}
}
else
{
switch (xboxControl)
{
case X360Controls.Start: tempControlDict.Add(DS4Controls.Options, dcs.control); break;
case X360Controls.Guide: tempControlDict.Add(DS4Controls.PS, dcs.control); break;
case X360Controls.Back: tempControlDict.Add(DS4Controls.Share, dcs.control); break;
default: break;
}
}
if (keyType.HasFlag(DS4KeyType.Toggle))
{
if (getBoolMapping(device, dcs.control, cState, eState, tp))
@ -968,6 +1025,7 @@ namespace DS4Windows
pressedonce[keyvalue] = false;
}
}
resetToDefaultValue(dcs.control, MappedState); // erase default mappings for things that are remapped
}
}
@ -2404,24 +2462,46 @@ namespace DS4Windows
//if control is one of the xy axis returns 127
//if its a trigger returns 0
public static void resetToDefaultValue(DS4Controls control, DS4State cState)
{
if (control >= DS4Controls.Square && control <= DS4Controls.Cross)
{
switch (control)
{
case DS4Controls.Share: cState.Share = false; break;
case DS4Controls.Options: cState.Options = false; break;
case DS4Controls.L1: cState.L1 = false; break;
case DS4Controls.R1: cState.R1 = false; break;
case DS4Controls.L3: cState.L3 = false; break;
case DS4Controls.R3: cState.R3 = false; break;
case DS4Controls.DpadUp: cState.DpadUp = false; break;
case DS4Controls.DpadDown: cState.DpadDown = false; break;
case DS4Controls.DpadLeft: cState.DpadLeft = false; break;
case DS4Controls.DpadRight: cState.DpadRight = false; break;
case DS4Controls.PS: cState.PS = false; break;
case DS4Controls.Cross: cState.Cross = false; break;
case DS4Controls.Square: cState.Square = false; break;
case DS4Controls.Triangle: cState.Triangle = false; break;
case DS4Controls.Circle: cState.Circle = false; break;
default: break;
}
}
else if (control >= DS4Controls.L1 && control <= DS4Controls.R3)
{
switch (control)
{
case DS4Controls.L1: cState.L1 = false; break;
case DS4Controls.L2: cState.L2 = 0; break;
case DS4Controls.L3: cState.L3 = false; break;
case DS4Controls.R1: cState.R1 = false; break;
case DS4Controls.R2: cState.R2 = 0; break;
case DS4Controls.R3: cState.R3 = false; break;
default: break;
}
}
else if (control >= DS4Controls.DpadUp && control <= DS4Controls.DpadLeft)
{
switch (control)
{
case DS4Controls.DpadUp: cState.DpadUp = false; break;
case DS4Controls.DpadDown: cState.DpadDown = false; break;
case DS4Controls.DpadLeft: cState.DpadLeft = false; break;
case DS4Controls.DpadRight: cState.DpadRight = false; break;
default: break;
}
}
else if (control >= DS4Controls.LXNeg && control <= DS4Controls.RYPos)
{
switch (control)
{
case DS4Controls.LXNeg: cState.LX = 127; break;
case DS4Controls.LYNeg: cState.LY = 127; break;
case DS4Controls.RXNeg: cState.RX = 127; break;
@ -2430,8 +2510,18 @@ namespace DS4Windows
case DS4Controls.LYPos: cState.LY = 127; break;
case DS4Controls.RXPos: cState.RX = 127; break;
case DS4Controls.RYPos: cState.RY = 127; break;
case DS4Controls.L2: cState.L2 = 0; break;
case DS4Controls.R2: cState.R2 = 0; break;
default: break;
}
}
else
{
switch (control)
{
case DS4Controls.Share: cState.Share = false; break;
case DS4Controls.Options: cState.Options = false; break;
case DS4Controls.PS: cState.PS = false; break;
default: break;
}
}
}
}