Skip to content

Commit

Permalink
Input device is now sent with the confirm.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Feb 28, 2024
1 parent 74c1e4a commit 63e8bb8
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ public enum ConfirmJoinedResult
public class ConfirmJoinedEventArgs : EventArgs
{
public ConfirmJoinedResult Result { get; private set; }
public IInputDevice InputDevice { get; private set; }

public ConfirmJoinedEventArgs(ConfirmJoinedResult result)
public ConfirmJoinedEventArgs(ConfirmJoinedResult result, IInputDevice inputDevice)
{
Result = result;
InputDevice = inputDevice;
}
}

Expand Down Expand Up @@ -241,19 +243,20 @@ bool DidUnjoin(IInputDevice inputDevice) =>

for(int i = 0; i < AllConnectedInputDevices.Count; i++)
{
var inputDevice = AllConnectedInputDevices[i];
// In this context, "Join" means to confirm the selection and advance
if(AllConnectedInputDevices[i].DefaultJoinInput.WasJustPressed)
if(inputDevice.DefaultJoinInput.WasJustPressed)
{
ConfirmJoinedResult result = ConfirmJoinedResult.Succeeded;
if (JoinedInputDevices.Contains(AllConnectedInputDevices[i]) == false)
if (JoinedInputDevices.Contains(inputDevice) == false)
{
result = ConfirmJoinedResult.InputDeviceNotJoined;
}
else if(joinedInputDeviceCount < MinPlayers)
{
result = ConfirmJoinedResult.NotEnoughPlayers;
}
var args = new ConfirmJoinedEventArgs(result);
var args = new ConfirmJoinedEventArgs(result, inputDevice);
ConfirmedJoinedInput?.Invoke(this, args);
break;
}
Expand Down

0 comments on commit 63e8bb8

Please sign in to comment.