Advertisement
Guest User

inputmapper

a guest
Jul 29th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. ButtonState[] state = new ButtonState[12];
  2.        
  3. /// <summary>
  4. /// Updates the status of the virtual controller.
  5. /// </summary>
  6. public void Update()
  7. {
  8.     PollState();
  9.  
  10.     for (int i = 0; i < 12; i++)
  11.     {
  12.         state[i] = (ButtonState)(((int)state[i]) >> 1);
  13.         if (IsButtonDown((Buttons)i))
  14.             state[i] |= ButtonState.Pressed;
  15.         }
  16.     }
  17. }
  18.  
  19. /// <summary>
  20. /// Polls the state of the physical input device.
  21. /// </summary>
  22. protected abstract void PollState();
  23.  
  24. /// <summary>
  25. /// Gets the current state of the specified virtual button from the physical input device.
  26. /// </summary>
  27. /// <param name="button">Identifies the virtual button whose state should be polled.</param>
  28. public abstract bool IsButtonDown(Buttons button);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement