diff --git a/ROADMAP.md b/ROADMAP.md index c3952a5..ce619e1 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -33,7 +33,8 @@ These are the plans for what I want to be customizable via .config modification ## Misc - Optionally assign "close" keybind to a combination of stick buttons ☐ -- Choose an XInput device instead of defaulting to whichever one is considered player 1 ☐ - - "Press Start" prompt if ambiguous, save to config file? +- Choose an XInput device instead of defaulting to whichever one is considered player 1 🗹 + - ~~"Press Start" prompt if ambiguous, save to config file?~~ + - Every frame, just use the controller with the lowest index and any input - Keybinds to generate .config file and default images in execution folder ☐ - This would allow the distribution of just the .exe file. If someone wishes to customize, those default resources could be generated from the program diff --git a/sticky_viewer/Display.cs b/sticky_viewer/Display.cs index 8e5b640..3f8beb9 100644 --- a/sticky_viewer/Display.cs +++ b/sticky_viewer/Display.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using System; using System.Collections.Generic; using System.Configuration; using System.IO; @@ -47,7 +48,6 @@ namespace sticky_viewer private Texture2D C; private Texture2D J; private Texture2D S; - public Display() { graphics = new GraphicsDeviceManager(this); @@ -149,7 +149,15 @@ namespace sticky_viewer Exit(); } - GamePadDPad dpad = GamePad.GetState(PlayerIndex.One).DPad; + // Find the controller being used currently + GamePadState emptyInput = new GamePadState(); + GamePadState currentState = new GamePadState(); + foreach (PlayerIndex p in Enum.GetValues(typeof(PlayerIndex))) + { + if ((currentState = GamePad.GetState(p)) != emptyInput) { break; } + } + + GamePadDPad dpad = currentState.DPad; if (dpad.Up == ButtonState.Pressed && dpad.Left == ButtonState.Pressed) { @@ -188,8 +196,6 @@ namespace sticky_viewer stick = neutral; } - GamePadState currentState = GamePad.GetState(PlayerIndex.One); - Dictionary inputs = new Dictionary() { {"A", currentState.Buttons.A == ButtonState.Pressed},