public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate) { base.HandleInput(input, receivedFocusInThisUpdate); if (input.IsNewKeyPress(Keys.Escape)) { Canceling(); } // Do nothing if base.HandleInput closing this screen right now if (m_state == MyGuiScreenState.CLOSING || m_state == MyGuiScreenState.HIDING) { return; } if (m_deviceType == MyGuiInputDeviceEnum.Keyboard) { List <Toolkit.Input.Keys> pressedKeys = new List <Toolkit.Input.Keys>(); input.GetListOfPressedKeys(pressedKeys); // don't assign keys that were pressed when we arrived in the menu foreach (var key in pressedKeys) { if (!m_oldPressedKeys.Contains(key)) { if (key == Keys.Control) { continue; //there is always LeftControl or RightControl pressed with this } if (key == Keys.Shift) { continue; //there is always LeftShift or RightShift pressed with this } MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); if (!MyGuiInput.IsKeyValid((Keys)key)) { ShowControlIsNotValidMessageBox(); break; } MyControl ctrl = input.GetControl((Keys)key, m_control.GetGameControlTypeEnum()); if (ctrl != null) { if (ctrl.Equals(m_control)) { CloseScreen(); return; } ShowControlIsAlreadyAssigned(ctrl); break; } m_control.SetControl((Keys)key); m_buttonsDictionary[m_control].SetText(new StringBuilder(m_control.GetControlButtonName(MyGuiInputDeviceEnum.Keyboard))); CloseScreen(); return; } } m_oldPressedKeys = pressedKeys; } else if (m_deviceType == MyGuiInputDeviceEnum.Mouse) { var pressedMouseButtons = new List <MyMouseButtonsEnum>(); input.GetListOfPressedMouseButtons(pressedMouseButtons); // don't assign buttons that were pressed when we arrived in the menu foreach (var button in pressedMouseButtons) { if (!m_oldPressedMouseButtons.Contains(button)) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); if (!MyGuiInput.IsMouseButtonValid(button)) { ShowControlIsNotValidMessageBox(); break; } MyControl ctrl = input.GetControl(button, m_control.GetGameControlTypeEnum()); if (ctrl != null) { if (ctrl.Equals(m_control)) { CloseScreen(); return; } ShowControlIsAlreadyAssigned(ctrl); break; } m_control.SetControl(button); m_buttonsDictionary[m_control].SetText(new StringBuilder(m_control.GetControlButtonName(MyGuiInputDeviceEnum.Mouse))); CloseScreen(); return; } } m_oldPressedMouseButtons = pressedMouseButtons; } else if (m_deviceType == MyGuiInputDeviceEnum.Joystick) { var pressedJoystickButtons = new List <MyJoystickButtonsEnum>(); input.GetListOfPressedJoystickButtons(pressedJoystickButtons); // don't assign buttons that were pressed when we arrived in the menu foreach (var button in pressedJoystickButtons) { if (!m_oldPressedJoystickButtons.Contains(button)) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); if (!MyGuiInput.IsJoystickButtonValid(button)) { ShowControlIsNotValidMessageBox(); break; } MyControl ctrl = input.GetControl(button, m_control.GetGameControlTypeEnum()); if (ctrl != null) { if (ctrl.Equals(m_control)) { CloseScreen(); return; } ShowControlIsAlreadyAssigned(ctrl); break; } m_control.SetControl(button); m_buttonsDictionary[m_control].SetText(new StringBuilder(m_control.GetControlButtonName(MyGuiInputDeviceEnum.Joystick))); CloseScreen(); return; } } m_oldPressedJoystickButtons = pressedJoystickButtons; } else if (m_deviceType == MyGuiInputDeviceEnum.JoystickAxis) { var pressedJoystickAxes = new List <MyJoystickAxesEnum>(); input.GetListOfPressedJoystickAxes(pressedJoystickAxes); // don't assign axes that were pressed when we arrived in the menu foreach (var axis in pressedJoystickAxes) { if (!m_oldPressedJoystickAxes.Contains(axis)) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); if (!MyGuiInput.IsJoystickAxisValid(axis)) { ShowControlIsNotValidMessageBox(); break; } MyControl ctrl = input.GetControl(axis, m_control.GetGameControlTypeEnum()); if (ctrl != null) { if (ctrl.Equals(m_control)) { CloseScreen(); return; } ShowControlIsAlreadyAssigned(ctrl); break; } m_control.SetControl(axis); m_buttonsDictionary[m_control].SetText(new StringBuilder(m_control.GetControlButtonName(MyGuiInputDeviceEnum.JoystickAxis))); CloseScreen(); return; } } m_oldPressedJoystickAxes = pressedJoystickAxes; } }