Exemple #1
0
 /// <summary>
 /// Polls all the controllers looking for the specified predicate to be true. The
 /// first controller matching the predicate is assigned to Controller.
 /// </summary>
 /// <param name="poll">The predicate to test.</param>
 /// <returns>True if a controller was selected; otherwise, false.</returns>
 public bool FindActiveController(PollIsDown poll)
 {
     for (PlayerIndex p = PlayerIndex.One; p <= PlayerIndex.Four; p++)
     {
         GamePadState state = PollState(0f, p);
         if (poll(state))
         {
             Controller = p;
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
 /// <summary>
 /// Registers a control state to be updated every frame.
 /// </summary>
 /// <param name="control">The control state to update.</param>
 /// <param name="pollFn">The polling function to update the control with.</param>
 public void Register(ControlState control, PollIsDown pollFn)
 {
     _stateCtrls.Add(control, pollFn);
 }