コード例 #1
0
 public static bool IsKeyPressed(JOYKEYS key, JOYBUTTONS pre)
 {
     return((PadState.buttons & PadState.set[key]) == PadState.set[key] && (pre & PadState.set[key]) != PadState.set[key]);
 }
コード例 #2
0
 public static JOYBUTTONS GetState(int ifjoy, int x, int y, int dwButtons)
 {
     PadState.buttons = JOYBUTTONS.None;
     if (ifjoy == 0)
     {
         if ((dwButtons & PadState.JOY_BUTTON1) == PadState.JOY_BUTTON1)
         {
             PadState.buttons |= JOYBUTTONS.B1;
         }
         if ((dwButtons & PadState.JOY_BUTTON2) == PadState.JOY_BUTTON2)
         {
             PadState.buttons |= JOYBUTTONS.B2;
         }
         if ((dwButtons & PadState.JOY_BUTTON3) == PadState.JOY_BUTTON3)
         {
             PadState.buttons |= JOYBUTTONS.B3;
         }
         if ((dwButtons & PadState.JOY_BUTTON4) == PadState.JOY_BUTTON4)
         {
             PadState.buttons |= JOYBUTTONS.B4;
         }
         if ((dwButtons & PadState.JOY_BUTTON5) == PadState.JOY_BUTTON5)
         {
             PadState.buttons |= JOYBUTTONS.B5;
         }
         if ((dwButtons & PadState.JOY_BUTTON6) == PadState.JOY_BUTTON6)
         {
             PadState.buttons |= JOYBUTTONS.B6;
         }
         if ((dwButtons & PadState.JOY_BUTTON7) == PadState.JOY_BUTTON7)
         {
             PadState.buttons |= JOYBUTTONS.B7;
         }
         if ((dwButtons & PadState.JOY_BUTTON8) == PadState.JOY_BUTTON8)
         {
             PadState.buttons |= JOYBUTTONS.B8;
         }
         if ((dwButtons & PadState.JOY_BUTTON9) == PadState.JOY_BUTTON9)
         {
             PadState.buttons |= JOYBUTTONS.B9;
         }
         if ((dwButtons & PadState.JOY_BUTTON10) == PadState.JOY_BUTTON10)
         {
             PadState.buttons |= JOYBUTTONS.B10;
         }
         int maxValue = (int)short.MaxValue;
         if (x - maxValue > 256)
         {
             PadState.buttons |= JOYBUTTONS.Right;
         }
         else if (maxValue - x > 256)
         {
             PadState.buttons |= JOYBUTTONS.Left;
         }
         if (y - maxValue > 256)
         {
             PadState.buttons |= JOYBUTTONS.Down;
         }
         else if (maxValue - y > 256)
         {
             PadState.buttons |= JOYBUTTONS.UP;
         }
     }
     return(PadState.buttons);
 }
コード例 #3
0
ファイル: Main.cs プロジェクト: THSJF/sjf
        protected override void Update(GameTime gameTime)
        {
            if (!Main.VSync)
            {
                Main.timewatch.Start();
            }
            int posEx = Main.joyGetPosEx(0, ref Main.padinfo);

            this.Window.Title = Main.WindowTitle;
            if (this.IsActive)
            {
                Main.keyboardstat = Keyboard.GetState();
                Main.padstat      = PadState.GetState(posEx, Main.padinfo.dwXpos, Main.padinfo.dwYpos, Main.padinfo.dwButtons);
            }
            if (this.entrance != null)
            {
                this.entrance.Update();
                if (this.entrance.Finished)
                {
                    this.entrance = (Entrance)null;
                    Main.gr       = new GameResource();
                }
            }
            if (this.game != null)
            {
                this.game.SUpdate();
                if (this.game.Finished)
                {
                    this.game = (Game)null;
                    if (!Main.stage.Contains("PRACTICE") && !Main.stage.Contains("GAME"))
                    {
                        Main.gr = new GameResource();
                    }
                }
            }
            if (this.ed != null)
            {
                this.ed.Update();
                if (this.ed.Finished)
                {
                    this.ed = (ED)null;
                }
            }
            if (Main.stagecheck != Main.stage)
            {
                if (Main.stage == "ENTRANCE")
                {
                    this.entrance = new Entrance(this.GraphicsDevice, Main.gr);
                }
                else if (Main.stage == "GAME")
                {
                    this.game     = new Game(this.GraphicsDevice, Main.gr);
                    Main.MKeys    = new bool[RecordManager.used.Length];
                    Main.preMKeys = new bool[RecordManager.used.Length];
                }
                else if (Main.stage.Contains("GAME"))
                {
                    this.game     = new Game(this.GraphicsDevice, Main.gr, int.Parse(Main.stage.Split(' ')[1]), int.Parse(Main.stage.Split(' ')[2]));
                    Main.MKeys    = new bool[RecordManager.used.Length];
                    Main.preMKeys = new bool[RecordManager.used.Length];
                }
                else if (Main.stage.Contains("PRACTICE"))
                {
                    this.game     = new Game(this.GraphicsDevice, Main.gr, int.Parse(Main.stage.Split(' ')[1]));
                    Main.MKeys    = new bool[RecordManager.used.Length];
                    Main.preMKeys = new bool[RecordManager.used.Length];
                }
                else if (Main.stage.Contains("ED"))
                {
                    this.ed = new ED((Main.ifcontinued ? 1 : 0) != 0, int.Parse(Main.stage.Split(' ')[1]), this.GraphicsDevice, Main.EDrecordsave, Main.EDreplaysave);
                }
            }
            Main.stagecheck = Main.stage;
            this.achivmanager.Update();
            ValueEventManager.Update();
            Music.Update();
            Sound.Update();
            Main.prekeyboard = Main.keyboardstat;
            Main.prepadstat  = Main.padstat;
            if (this.game == null)
            {
                return;
            }
            this.game.PreReadSave();
        }