Change input key method to return DS4Controls value instead of string

This commit is contained in:
Travis Nickles 2017-08-22 19:52:32 -05:00
parent 0817da3864
commit 2ea4967486
2 changed files with 62 additions and 124 deletions

View File

@ -839,131 +839,73 @@ namespace DS4Windows
} }
} }
public string GetInputkeys(int ind) public DS4Controls GetActiveInputControl(int ind)
{ {
DS4State cState = CurrentState[ind]; DS4State cState = CurrentState[ind];
DS4StateExposed eState = ExposedState[ind]; DS4StateExposed eState = ExposedState[ind];
Mouse tp = touchPad[ind]; Mouse tp = touchPad[ind];
string result = "nothing"; DS4Controls result = DS4Controls.None;
if (DS4Controllers[ind] != null) if (DS4Controllers[ind] != null)
{ {
if (Mapping.getBoolButtonMapping(cState.Cross)) if (Mapping.getBoolButtonMapping(cState.Cross))
{ result = DS4Controls.Cross;
result = "Cross";
}
else if (Mapping.getBoolButtonMapping(cState.Circle)) else if (Mapping.getBoolButtonMapping(cState.Circle))
{ result = DS4Controls.Circle;
result = "Circle";
}
else if (Mapping.getBoolButtonMapping(cState.Triangle)) else if (Mapping.getBoolButtonMapping(cState.Triangle))
{ result = DS4Controls.Triangle;
result = "Triangle";
}
else if (Mapping.getBoolButtonMapping(cState.Square)) else if (Mapping.getBoolButtonMapping(cState.Square))
{ result = DS4Controls.Square;
result = "Square";
}
else if (Mapping.getBoolButtonMapping(cState.L1)) else if (Mapping.getBoolButtonMapping(cState.L1))
{ result = DS4Controls.L1;
result = "L1";
}
else if (Mapping.getBoolTriggerMapping(cState.L2)) else if (Mapping.getBoolTriggerMapping(cState.L2))
{ result = DS4Controls.L2;
result = "L2";
}
else if (Mapping.getBoolButtonMapping(cState.L3)) else if (Mapping.getBoolButtonMapping(cState.L3))
{ result = DS4Controls.L3;
result = "L3";
}
else if (Mapping.getBoolButtonMapping(cState.R1)) else if (Mapping.getBoolButtonMapping(cState.R1))
{ result = DS4Controls.R1;
result = "R1";
}
else if (Mapping.getBoolTriggerMapping(cState.R2)) else if (Mapping.getBoolTriggerMapping(cState.R2))
{ result = DS4Controls.R2;
result = "R2";
}
else if (Mapping.getBoolButtonMapping(cState.R3)) else if (Mapping.getBoolButtonMapping(cState.R3))
{ result = DS4Controls.R3;
result = "R3";
}
else if (Mapping.getBoolButtonMapping(cState.DpadUp)) else if (Mapping.getBoolButtonMapping(cState.DpadUp))
{ result = DS4Controls.DpadUp;
result = "Up";
}
else if (Mapping.getBoolButtonMapping(cState.DpadDown)) else if (Mapping.getBoolButtonMapping(cState.DpadDown))
{ result = DS4Controls.DpadDown;
result = "Down";
}
else if (Mapping.getBoolButtonMapping(cState.DpadLeft)) else if (Mapping.getBoolButtonMapping(cState.DpadLeft))
{ result = DS4Controls.DpadLeft;
result = "Left";
}
else if (Mapping.getBoolButtonMapping(cState.DpadRight)) else if (Mapping.getBoolButtonMapping(cState.DpadRight))
{ result = DS4Controls.DpadRight;
result = "Right";
}
else if (Mapping.getBoolButtonMapping(cState.Share)) else if (Mapping.getBoolButtonMapping(cState.Share))
{ result = DS4Controls.Share;
result = "Share";
}
else if (Mapping.getBoolButtonMapping(cState.Options)) else if (Mapping.getBoolButtonMapping(cState.Options))
{ result = DS4Controls.Options;
result = "Options";
}
else if (Mapping.getBoolButtonMapping(cState.PS)) else if (Mapping.getBoolButtonMapping(cState.PS))
{ result = DS4Controls.PS;
result = "PS";
}
else if (Mapping.getBoolAxisDirMapping(cState.LX, true)) else if (Mapping.getBoolAxisDirMapping(cState.LX, true))
{ result = DS4Controls.LXPos;
result = "LS Right";
}
else if (Mapping.getBoolAxisDirMapping(cState.LX, false)) else if (Mapping.getBoolAxisDirMapping(cState.LX, false))
{ result = DS4Controls.LXNeg;
result = "LS Left";
}
else if (Mapping.getBoolAxisDirMapping(cState.LY, true)) else if (Mapping.getBoolAxisDirMapping(cState.LY, true))
{ result = DS4Controls.LYPos;
result = "LS Down";
}
else if (Mapping.getBoolAxisDirMapping(cState.LY, false)) else if (Mapping.getBoolAxisDirMapping(cState.LY, false))
{ result = DS4Controls.LYNeg;
result = "LS Up";
}
else if (Mapping.getBoolAxisDirMapping(cState.RX, true)) else if (Mapping.getBoolAxisDirMapping(cState.RX, true))
{ result = DS4Controls.RXPos;
result = "RS Right";
}
else if (Mapping.getBoolAxisDirMapping(cState.RX, false)) else if (Mapping.getBoolAxisDirMapping(cState.RX, false))
{ result = DS4Controls.RXNeg;
result = "RS Left";
}
else if (Mapping.getBoolAxisDirMapping(cState.RY, true)) else if (Mapping.getBoolAxisDirMapping(cState.RY, true))
{ result = DS4Controls.RYPos;
result = "RS Down";
}
else if (Mapping.getBoolAxisDirMapping(cState.RY, false)) else if (Mapping.getBoolAxisDirMapping(cState.RY, false))
{ result = DS4Controls.RYNeg;
result = "RS Up";
}
else if (Mapping.getBoolTouchMapping(tp.leftDown)) else if (Mapping.getBoolTouchMapping(tp.leftDown))
{ result = DS4Controls.TouchLeft;
result = "Touch Left";
}
else if (Mapping.getBoolTouchMapping(tp.rightDown)) else if (Mapping.getBoolTouchMapping(tp.rightDown))
{ result = DS4Controls.TouchRight;
result = "Touch Right";
}
else if (Mapping.getBoolTouchMapping(tp.multiDown)) else if (Mapping.getBoolTouchMapping(tp.multiDown))
{ result = DS4Controls.TouchMulti;
result = "Touch Multi";
}
else if (Mapping.getBoolTouchMapping(tp.upperDown)) else if (Mapping.getBoolTouchMapping(tp.upperDown))
{ result = DS4Controls.TouchUpper;
result = "Touch Upper";
}
} }
return result; return result;

View File

@ -1053,42 +1053,38 @@ namespace DS4Windows
if (Form.ActiveForm == root && cBControllerInput.Checked && tCControls.SelectedIndex < 1) if (Form.ActiveForm == root && cBControllerInput.Checked && tCControls.SelectedIndex < 1)
{ {
int tempDeviceNum = (int)nUDSixaxis.Value - 1; int tempDeviceNum = (int)nUDSixaxis.Value - 1;
switch (Program.rootHub.GetInputkeys(tempDeviceNum)) switch (Program.rootHub.GetActiveInputControl(tempDeviceNum))
{ {
case ("nothing"): break; case DS4Controls.None: break;
case ("Cross"): Show_ControlsBn(bnCross, e); break; case DS4Controls.Cross: Show_ControlsBn(bnCross, e); break;
case ("Circle"): Show_ControlsBn(bnCircle, e); break; case DS4Controls.Circle: Show_ControlsBn(bnCircle, e); break;
case ("Square"): Show_ControlsBn(bnSquare, e); break; case DS4Controls.Square: Show_ControlsBn(bnSquare, e); break;
case ("Triangle"): Show_ControlsBn(bnTriangle, e); break; case DS4Controls.Triangle: Show_ControlsBn(bnTriangle, e); break;
case ("Options"): Show_ControlsBn(bnOptions, e); break; case DS4Controls.Options: Show_ControlsBn(bnOptions, e); break;
case ("Share"): Show_ControlsBn(bnShare, e); break; case DS4Controls.Share: Show_ControlsBn(bnShare, e); break;
case ("Up"): Show_ControlsBn(bnUp, e); break; case DS4Controls.DpadUp: Show_ControlsBn(bnUp, e); break;
case ("Down"): Show_ControlsBn(bnDown, e); break; case DS4Controls.DpadDown: Show_ControlsBn(bnDown, e); break;
case ("Left"): Show_ControlsBn(bnLeft, e); break; case DS4Controls.DpadLeft: Show_ControlsBn(bnLeft, e); break;
case ("Right"): Show_ControlsBn(bnRight, e); break; case DS4Controls.DpadRight: Show_ControlsBn(bnRight, e); break;
case ("PS"): Show_ControlsBn(bnPS, e); break; case DS4Controls.PS: Show_ControlsBn(bnPS, e); break;
case ("L1"): Show_ControlsBn(bnL1, e); break; case DS4Controls.L1: Show_ControlsBn(bnL1, e); break;
case ("R1"): Show_ControlsBn(bnR1, e); break; case DS4Controls.R1: Show_ControlsBn(bnR1, e); break;
case ("L2"): Show_ControlsBn(bnL2, e); break; case DS4Controls.L2: Show_ControlsBn(bnL2, e); break;
case ("R2"): Show_ControlsBn(bnR2, e); break; case DS4Controls.R2: Show_ControlsBn(bnR2, e); break;
case ("L3"): Show_ControlsBn(bnL3, e); break; case DS4Controls.L3: Show_ControlsBn(bnL3, e); break;
case ("R3"): Show_ControlsBn(bnR3, e); break; case DS4Controls.R3: Show_ControlsBn(bnR3, e); break;
case ("Touch Left"): Show_ControlsBn(bnTouchLeft, e); break; case DS4Controls.TouchLeft: Show_ControlsBn(bnTouchLeft, e); break;
case ("Touch Right"): Show_ControlsBn(bnTouchRight, e); break; case DS4Controls.TouchRight: Show_ControlsBn(bnTouchRight, e); break;
case ("Touch Multi"): Show_ControlsBn(bnTouchMulti, e); break; case DS4Controls.TouchMulti: Show_ControlsBn(bnTouchMulti, e); break;
case ("Touch Upper"): Show_ControlsBn(bnTouchUpper, e); break; case DS4Controls.TouchUpper: Show_ControlsBn(bnTouchUpper, e); break;
case ("LS Up"): Show_ControlsBn(bnLSUp, e); break; case DS4Controls.LYNeg: Show_ControlsBn(bnLSUp, e); break;
case ("LS Down"): Show_ControlsBn(bnLSDown, e); break; case DS4Controls.LYPos: Show_ControlsBn(bnLSDown, e); break;
case ("LS Left"): Show_ControlsBn(bnLSLeft, e); break; case DS4Controls.LXNeg: Show_ControlsBn(bnLSLeft, e); break;
case ("LS Right"): Show_ControlsBn(bnLSRight, e); break; case DS4Controls.LXPos: Show_ControlsBn(bnLSRight, e); break;
case ("RS Up"): Show_ControlsBn(bnRSUp, e); break; case DS4Controls.RYNeg: Show_ControlsBn(bnRSUp, e); break;
case ("RS Down"): Show_ControlsBn(bnRSDown, e); break; case DS4Controls.RYPos: Show_ControlsBn(bnRSDown, e); break;
case ("RS Left"): Show_ControlsBn(bnRSLeft, e); break; case DS4Controls.RXNeg: Show_ControlsBn(bnRSLeft, e); break;
case ("RS Right"): Show_ControlsBn(bnRSRight, e); break; case DS4Controls.RXPos: 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;
default: break; default: break;
} }
} }