private void SdlUpdate(TimeSpan elapsed) { this.sinceCheckedConnected += elapsed; if (this.sinceCheckedConnected >= GamepadState.ConnectedCheckFrequency) { bool sdlConnected = this.SdlConnected; this.SdlConnected = SdlGamePad.GetState(this.PlayerIndex).IsConnected; if (sdlConnected && !this.SdlConnected) { this.NewlyDisconnected = true; } } if (!this.SdlConnected) { return; } GamePadState state; try { state = SdlGamePad.GetState(this.PlayerIndex, GamePadDeadZone.IndependentAxes); } catch { return; } this.SdlConnected = state.IsConnected; if (!this.SdlConnected) { return; } this.UpdateFromState(state, elapsed); }
static SettingsManager() { if (Enumerable.Any <DisplayMode>((IEnumerable <DisplayMode>)SettingsManager.Resolutions, (Func <DisplayMode, bool>)(x => { if (x.Width >= 1280) { return(x.Height >= 720); } else { return(false); } }))) { SettingsManager.Resolutions.RemoveAll((Predicate <DisplayMode>)(x => { if (x.Width < 1280) { return(true); } if (x.Height < 720) { return(x != SettingsManager.NativeResolution); } else { return(false); } })); } string str1 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FEZ"); if (!Directory.Exists(str1)) { Directory.CreateDirectory(str1); } string str2 = Path.Combine(str1, "Settings"); SettingsManager.FirstOpen = !File.Exists(str2); if (SettingsManager.FirstOpen) { SettingsManager.Settings = new Settings(); } else { try { SettingsManager.Settings = SdlSerializer.Deserialize <Settings>(str2); } catch (Exception ex) { SettingsManager.Settings = new Settings(); } } SdlGamePad.GetState(PlayerIndex.One); SettingsManager.Settings.ApplyGamepadMapping(); Culture.Language = SettingsManager.Settings.Language; SettingsManager.Save(); }
public override void Reset() { base.Reset(); this.Items[this.selectorStart].Hidden = true; this.Items[this.selectorStart].Selectable = false; this.Items[this.selectorStart + 1].Hidden = true; this.Items[this.selectorStart + 1].Selectable = false; this.Items[this.selectorStart + 2].Hidden = true; this.Items[this.selectorStart + 2].Selectable = false; this.chosen = this.Items.Count - 1; this.FakeSlideRight(true); this.noArrows = SdlGamePad.GetPadCount() == 0 && !GamepadState.AnyXInputConnected; }
protected override void Dispose(bool disposing) { if (!this.IsDisposed && this._view != null) { this._view.Dispose(); this._view = (OpenTKGameWindow)null; } if (this.soundControllerInstance != null) { this.soundControllerInstance.Dispose(); } SdlGamePad.Cleanup(); WindowsHelperAccessibilityKeys.AllowAccessibilityShortcutKeys(true); base.Dispose(disposing); }
private void FakeSlideLeft(bool silent = false) { this.Items[this.chosen].Hidden = true; this.Items[this.chosen].Selectable = false; int num1 = this.chosen; --this.chosen; if ((SdlGamePad.GetPadCount() == 0 || GamepadState.AnyXInputConnected) && this.chosen == this.selectorStart + 1) { --this.chosen; } if (!GamepadState.AnyXInputConnected && this.chosen == this.selectorStart) { --this.chosen; } if (this.chosen == this.selectorStart - 1) { this.chosen = this.Items.Count - 1; } int num2 = this.chosen - this.selectorStart; for (int index = 0; index < this.otherGamepadsStart; ++index) { this.Items[index].Hidden = num2 != 0; } for (int index = this.otherGamepadsStart; index < this.keyboardStart; ++index) { this.Items[index].Hidden = num2 != 1; } for (int index = this.keyboardStart; index < this.selectorStart; ++index) { this.Items[index].Hidden = num2 != 2; } this.Items[this.chosen].Hidden = false; this.Items[this.chosen].Selectable = true; this.SelectedIndex = this.chosen; if (silent || num1 == this.chosen) { return; } SoundEffectExtensions.Emit(this.sSliderValueDecrease); }
public void ApplyGamepadMapping() { for (PlayerIndex index = PlayerIndex.One; index < (PlayerIndex)SdlGamePad.GetPadCount(); ++index) { PadConfig config = SdlGamePad.GetConfig(index); if (config != null) { config.Button_A.ID = this.GamepadMapping[MappedAction.Jump]; config.Button_B.ID = this.GamepadMapping[MappedAction.CancelTalk]; config.Button_X.ID = this.GamepadMapping[MappedAction.GrabThrow]; config.Button_Y.ID = this.GamepadMapping[MappedAction.OpenInventory]; config.Button_LB.ID = this.GamepadMapping[MappedAction.MapZoomOut]; config.Button_RB.ID = this.GamepadMapping[MappedAction.MapZoomIn]; config.LeftTrigger.ID = this.GamepadMapping[MappedAction.RotateLeft]; config.RightTrigger.ID = this.GamepadMapping[MappedAction.RotateRight]; config.Button_Back.ID = this.GamepadMapping[MappedAction.OpenMap]; config.Button_Start.ID = this.GamepadMapping[MappedAction.Pause]; config.LeftStick.Press.ID = this.GamepadMapping[MappedAction.FpViewToggle]; config.RightStick.Press.ID = this.GamepadMapping[MappedAction.ClampLook]; } } }
public override void Update(TimeSpan elapsed) { base.Update(elapsed); if (this.pendingApply && !SdlGamePad.GetPressedButtonId().HasValue) { this.pendingApply = false; SettingsManager.Settings.ApplyGamepadMapping(); } if (this.TrapInput) { if (this.forGamepad) { if (this.KeyboardManager.GetKeyState(Keys.Escape) == FezButtonState.Pressed) { int num = this.Items.IndexOf(this.keyGrabFor); MappedAction mappedAction = ControlsMenuLevel.GamepadActionOrder[num - this.otherGamepadsStart]; Dictionary <MappedAction, int> gMap = SettingsManager.Settings.GamepadMapping; this.keyGrabFor.SuffixText = (Func <string>)(() => " : " + this.Buttonize(gMap[mappedAction])); this.TrapInput = false; this.forGamepad = false; this.pendingApply = true; } else { int?pressedButtonId = SdlGamePad.GetPressedButtonId(); ControlsMenuLevel controlsMenuLevel = this; int num1 = controlsMenuLevel.hasBeenIdle | !pressedButtonId.HasValue ? 1 : 0; controlsMenuLevel.hasBeenIdle = num1 != 0; if (this.hasBeenIdle && pressedButtonId.HasValue) { int num2 = this.Items.IndexOf(this.keyGrabFor); MappedAction mappedAction = ControlsMenuLevel.GamepadActionOrder[num2 - this.otherGamepadsStart]; Dictionary <MappedAction, int> gMap = SettingsManager.Settings.GamepadMapping; gMap[mappedAction] = pressedButtonId.Value; this.keyGrabFor.SuffixText = (Func <string>)(() => " : " + this.Buttonize(gMap[mappedAction])); this.TrapInput = false; this.forGamepad = false; this.pendingApply = true; } } } else { this.thisPressed.Clear(); foreach (Keys keys in Keyboard.GetState().GetPressedKeys()) { this.thisPressed.Add(keys); } foreach (Keys keys1 in this.keysDown) { if (!this.thisPressed.Contains(keys1)) { Keys keys2 = keys1; int num = this.Items.IndexOf(this.keyGrabFor); MappedAction mappedAction = ControlsMenuLevel.KeyboardActionOrder[num - this.keyboardStart]; Dictionary <MappedAction, Keys> kMap = SettingsManager.Settings.KeyboardMapping; kMap[mappedAction] = keys2; this.keyGrabFor.SuffixText = (Func <string>)(() => " : " + this.Localize((object)kMap[mappedAction])); this.KeyboardManager.UpdateMapping(); this.TrapInput = false; break; } } foreach (Keys keys in this.thisPressed) { if (!this.lastPressed.Contains(keys)) { this.keysDown.Add(keys); } } HashSet <Keys> hashSet = this.thisPressed; this.thisPressed = this.lastPressed; this.lastPressed = hashSet; } } if (this.SelectedIndex < this.Items.Count - 3) { return; } Point position = this.MouseState.Position; if (this.leftSliderRect.HasValue && this.leftSliderRect.Value.Contains(position)) { this.menuBase.CursorSelectable = true; if (this.MouseState.LeftButton.State == MouseButtonStates.Pressed) { this.FakeSlideLeft(false); } } else if (this.rightSliderRect.HasValue && this.rightSliderRect.Value.Contains(position)) { this.menuBase.CursorSelectable = true; if (this.MouseState.LeftButton.State == MouseButtonStates.Pressed) { this.FakeSlideRight(false); } } if (this.InputManager.Right == FezButtonState.Pressed) { this.FakeSlideRight(false); } else { if (this.InputManager.Left != FezButtonState.Pressed) { return; } this.FakeSlideLeft(false); } }