It was not hard at all, generally only these few lines:
GamePadState gamePad = GamePad.GetState(PlayerIndex.One);
bool moveLeft = Keyboard.GetState().IsKeyDown(Keys.Left)
|| gamePad.IsButtonDown(Buttons.DPadLeft);
bool moveRight = Keyboard.GetState().IsKeyDown(Keys.Right)
|| gamePad.IsButtonDown(Buttons.DPadRight);
bool run = Keyboard.GetState().IsKeyDown(Keys.LeftControl)
|| gamePad.IsButtonDown(Buttons.X);
bool jump = Keyboard.GetState().IsKeyDown(Keys.Up)
|| Keyboard.GetState().IsKeyDown(Keys.Space)
|| gamePad.IsButtonDown(Buttons.DPadUp)
|| gamePad.IsButtonDown(Buttons.A);
bool moveLeft = Keyboard.GetState().IsKeyDown(Keys.Left)
|| gamePad.IsButtonDown(Buttons.DPadLeft);
bool moveRight = Keyboard.GetState().IsKeyDown(Keys.Right)
|| gamePad.IsButtonDown(Buttons.DPadRight);
bool run = Keyboard.GetState().IsKeyDown(Keys.LeftControl)
|| gamePad.IsButtonDown(Buttons.X);
bool jump = Keyboard.GetState().IsKeyDown(Keys.Up)
|| Keyboard.GetState().IsKeyDown(Keys.Space)
|| gamePad.IsButtonDown(Buttons.DPadUp)
|| gamePad.IsButtonDown(Buttons.A);
This and poof, the controller is now working with the game :) The rewriting of collision detection still remains -_-'
P.S. Yes, the controller works with Windows without any weird unofficial drivers or adapters. In fact, the controller is designed with a USB contact and has official Windows drivers for full support on Windows.

0 comments:
Post a Comment