/// <summary>Called when a button on the gamepad has been pressed</summary> /// <param name="button">Button that has been pressed</param> public void InjectButtonPress(Buttons button) { var newHeldButtons = _heldButtons | button; if (newHeldButtons == _heldButtons) { return; } _heldButtons = newHeldButtons; // If a control is activated, it will receive any input notifications if (_activatedControl != null) { _activatedControl.ProcessButtonPress(button); return; } // No control is activated, try the focused control before searching // the entire tree for a responder. var focusedControl = _focusedControl.Target; if (focusedControl != null) { if (focusedControl.ProcessButtonPress(button)) { _activatedControl = focusedControl; return; } } // Focused control didn't process the notification, now let the desktop // control traverse the entire control tree is earch for a handler. if (_desktopControl.ProcessButtonPress(button)) { _activatedControl = _desktopControl; } }