Beispiel #1
0
 private static Settings PrepSettings()
 {
     if (SdlGamePad.settings == null)
     {
         SdlGamePad.settings = new Settings();
         SdlGamePad.AutoConfig();
     }
     else if (!SdlGamePad.running)
     {
         SdlGamePad.Init();
         return(SdlGamePad.settings);
     }
     if (!SdlGamePad.running)
     {
         SdlGamePad.Init();
     }
     return(SdlGamePad.settings);
 }
Beispiel #2
0
        private static void AutoConfig()
        {
            SdlGamePad.Init();
            if (!SdlGamePad.sdl)
            {
                return;
            }
            int num = Math.Min(4, Sdl.SDL_NumJoysticks());

            for (int index = 0; index < num; ++index)
            {
                PadConfig padConfig = new PadConfig(Sdl.SDL_JoystickName(index), index);
                SdlGamePad.devices[index]                = Sdl.SDL_JoystickOpen(padConfig.Index);
                padConfig.Button_A.ID                    = 1;
                padConfig.Button_A.Type                  = InputType.Button;
                padConfig.Button_B.ID                    = 2;
                padConfig.Button_B.Type                  = InputType.Button;
                padConfig.Button_X.ID                    = 0;
                padConfig.Button_X.Type                  = InputType.Button;
                padConfig.Button_Y.ID                    = 3;
                padConfig.Button_Y.Type                  = InputType.Button;
                padConfig.Button_LB.ID                   = 4;
                padConfig.Button_LB.Type                 = InputType.Button;
                padConfig.Button_RB.ID                   = 5;
                padConfig.Button_RB.Type                 = InputType.Button;
                padConfig.Button_Back.ID                 = 8;
                padConfig.Button_Back.Type               = InputType.Button;
                padConfig.Button_Start.ID                = 9;
                padConfig.Button_Start.Type              = InputType.Button;
                padConfig.LeftStick.Press.ID             = 10;
                padConfig.LeftStick.Press.Type           = InputType.Button;
                padConfig.RightStick.Press.ID            = 11;
                padConfig.RightStick.Press.Type          = InputType.Button;
                padConfig.LeftStick.X.Negative.ID        = 0;
                padConfig.LeftStick.X.Negative.Type      = InputType.Axis;
                padConfig.LeftStick.X.Negative.Negative  = true;
                padConfig.LeftStick.X.Positive.ID        = 0;
                padConfig.LeftStick.X.Positive.Type      = InputType.Axis;
                padConfig.LeftStick.X.Positive.Negative  = false;
                padConfig.LeftStick.Y.Negative.ID        = 1;
                padConfig.LeftStick.Y.Negative.Type      = InputType.Axis;
                padConfig.LeftStick.Y.Negative.Negative  = true;
                padConfig.LeftStick.Y.Positive.ID        = 1;
                padConfig.LeftStick.Y.Positive.Type      = InputType.Axis;
                padConfig.LeftStick.Y.Positive.Negative  = false;
                padConfig.RightStick.X.Negative.ID       = 2;
                padConfig.RightStick.X.Negative.Type     = InputType.Axis;
                padConfig.RightStick.X.Negative.Negative = true;
                padConfig.RightStick.X.Positive.ID       = 2;
                padConfig.RightStick.X.Positive.Type     = InputType.Axis;
                padConfig.RightStick.X.Positive.Negative = false;
                padConfig.RightStick.Y.Negative.ID       = 3;
                padConfig.RightStick.Y.Negative.Type     = InputType.Axis;
                padConfig.RightStick.Y.Negative.Negative = true;
                padConfig.RightStick.Y.Positive.ID       = 3;
                padConfig.RightStick.Y.Positive.Type     = InputType.Axis;
                padConfig.RightStick.Y.Positive.Negative = false;
                padConfig.Dpad.Up.ID        = 0;
                padConfig.Dpad.Up.Type      = InputType.PovUp;
                padConfig.Dpad.Down.ID      = 0;
                padConfig.Dpad.Down.Type    = InputType.PovDown;
                padConfig.Dpad.Left.ID      = 0;
                padConfig.Dpad.Left.Type    = InputType.PovLeft;
                padConfig.Dpad.Right.ID     = 0;
                padConfig.Dpad.Right.Type   = InputType.PovRight;
                padConfig.LeftTrigger.ID    = 6;
                padConfig.LeftTrigger.Type  = InputType.Button;
                padConfig.RightTrigger.ID   = 7;
                padConfig.RightTrigger.Type = InputType.Button;
                SdlGamePad.settings[index]  = padConfig;
            }
        }