private string RemapButtonName(string button) { // Do we even have a source? if (PlayerSource == -1) { return(button); } // See if we're being asked for a button that we know how to rewire var bnp = ButtonNameParser.Parse(button); if (bnp == null) { return(button); } // Ok, this looks like a normal `P1 Button` type thing. we can handle it // Were we supposed to replace this one? int foundPlayerMask = 1 << bnp.PlayerNum; if ((PlayerTargetMask & foundPlayerMask) == 0) { return(button); } // Ok, we were. swap out the source player and then grab his button bnp.PlayerNum = PlayerSource; return(bnp.ToString()); }
public void SetPlayerFrom(IController playerSource, int controllerNum) { foreach (var button in playerSource.Definition.BoolButtons) { var bnp = ButtonNameParser.Parse(button); if (bnp?.PlayerNum != controllerNum) { continue; } var val = playerSource.IsPressed(button); _myBoolButtons[button] = val; } foreach (var button in Definition.AxisControls) { var bnp = ButtonNameParser.Parse(button); if (bnp?.PlayerNum != controllerNum) { continue; } var val = playerSource.AxisValue(button); _myAxisControls[button] = val; } }
/// <summary> /// latches one player from the source /// </summary> public void LatchPlayerFromSource(IController playerSource, int playerNum) { foreach (var button in playerSource.Definition.BoolButtons) { var bnp = ButtonNameParser.Parse(button); if (bnp?.PlayerNum != playerNum) { continue; } var val = playerSource.IsPressed(button); _myBoolButtons[button] = val; } foreach (var button in Definition.FloatControls) { var bnp = ButtonNameParser.Parse(button); if (bnp?.PlayerNum != playerNum) { continue; } var val = playerSource.GetFloat(button); _myFloatControls[button] = val; } }
/// <summary> /// latches one player from the source /// </summary> public void LatchPlayerFromSource(IController playerSource, int playerNum) { foreach (var button in playerSource.Definition.BoolButtons) { var bnp = ButtonNameParser.Parse(button); if (bnp == null) { continue; } if (bnp.PlayerNum != playerNum) { continue; } var val = playerSource.IsPressed(button); MyBoolButtons[button] = val; } }
/// <summary> /// latches one player from the source /// </summary> public void LatchPlayerFromSource(IController playerSource, int playerNum) { foreach (var button in playerSource.Type.BoolButtons) { var bnp = ButtonNameParser.Parse(button); if (bnp == null) { continue; } if (bnp.PlayerNum != playerNum) { continue; } var val = playerSource[button]; MyBoolButtons[button] = val; } foreach (var button in Type.FloatControls) { var bnp = ButtonNameParser.Parse(button); if (bnp == null) { continue; } if (bnp.PlayerNum != playerNum) { continue; } var val = playerSource.GetFloat(button); MyFloatControls[button] = val; } }