private void checkBox_CheckedChanged(object sender, EventArgs e)
 {
     SelectedButtons =
         (checkBoxA.Checked ? SnesButtons.A : 0) |
         (checkBoxB.Checked ? SnesButtons.B : 0) |
         (checkBoxSelect.Checked ? SnesButtons.Select : 0) |
         (checkBoxStart.Checked ? SnesButtons.Start : 0) |
         (checkBoxUp.Checked ? SnesButtons.Up : 0) |
         (checkBoxDown.Checked ? SnesButtons.Down : 0) |
         (checkBoxLeft.Checked ? SnesButtons.Left : 0) |
         (checkBoxRight.Checked ? SnesButtons.Right : 0) |
         (checkBoxX.Checked ? SnesButtons.X : 0) |
         (checkBoxY.Checked ? SnesButtons.Y : 0) |
         (checkBoxL.Checked ? SnesButtons.L : 0) |
         (checkBoxR.Checked ? SnesButtons.R : 0);
 }
 public SelectSnesButtonsForm(SnesButtons buttons)
 {
     InitializeComponent();
     checkBoxA.Checked      = (buttons & SnesButtons.A) != 0;
     checkBoxB.Checked      = (buttons & SnesButtons.B) != 0;
     checkBoxSelect.Checked = (buttons & SnesButtons.Select) != 0;
     checkBoxStart.Checked  = (buttons & SnesButtons.Start) != 0;
     checkBoxUp.Checked     = (buttons & SnesButtons.Up) != 0;
     checkBoxDown.Checked   = (buttons & SnesButtons.Down) != 0;
     checkBoxLeft.Checked   = (buttons & SnesButtons.Left) != 0;
     checkBoxRight.Checked  = (buttons & SnesButtons.Right) != 0;
     checkBoxX.Checked      = (buttons & SnesButtons.X) != 0;
     checkBoxY.Checked      = (buttons & SnesButtons.Y) != 0;
     checkBoxL.Checked      = (buttons & SnesButtons.L) != 0;
     checkBoxR.Checked      = (buttons & SnesButtons.R) != 0;
     SelectedButtons        = buttons;
 }
Exemplo n.º 3
0
        public Command(string name, string cmdText)
        {
            this.Name = name;

            List <ButtonPress> presses = new List <ButtonPress>();

            string[] parts = cmdText.Split('|');
            for (int i = 0; i < parts.Length; i++)
            {
                string[] current = parts[i].Split('x');
                int      frames  = 1;
                if (current.Length > 1)
                {
                    frames = int.Parse(current[1]);
                }
                SnesButtons buttons = (SnesButtons)Enum.Parse(typeof(SnesButtons), current[0]);
                presses.Add(new ButtonPress(frames, buttons));
            }
            this.ButtonPresses = presses.ToArray();
        }
Exemplo n.º 4
0
        void AddButtons(SnesButtons buttons)
        {
            Joypad controller = ClientApi.GetInput(1);

            controller.ClearInputs();
            ClientApi.SetInput(1, controller);

            // D Pad
            if (buttons.HasFlag(SnesButtons.Left))
            {
                controller.AddInput(JoypadButton.Left);
            }
            if (buttons.HasFlag(SnesButtons.Right))
            {
                controller.AddInput(JoypadButton.Right);
            }
            if (buttons.HasFlag(SnesButtons.Down))
            {
                controller.AddInput(JoypadButton.Down);
            }
            if (buttons.HasFlag(SnesButtons.Up))
            {
                controller.AddInput(JoypadButton.Up);
            }

            // Toward/Away
            if (buttons.HasFlag(SnesButtons.Toward))
            {
                controller.AddInput(this.radioButtonLeft.Checked ? JoypadButton.Left : JoypadButton.Right);
            }
            if (buttons.HasFlag(SnesButtons.Away))
            {
                controller.AddInput(this.radioButtonLeft.Checked ? JoypadButton.Right : JoypadButton.Left);
            }

            // Face Buttons
            if (buttons.HasFlag(SnesButtons.A))
            {
                controller.AddInput(JoypadButton.A);
            }
            if (buttons.HasFlag(SnesButtons.B))
            {
                controller.AddInput(JoypadButton.B);
            }
            if (buttons.HasFlag(SnesButtons.X))
            {
                controller.AddInput(JoypadButton.X);
            }
            if (buttons.HasFlag(SnesButtons.Y))
            {
                controller.AddInput(JoypadButton.Y);
            }

            // S/s
            if (buttons.HasFlag(SnesButtons.Select))
            {
                controller.AddInput(JoypadButton.Select);
            }
            if (buttons.HasFlag(SnesButtons.Start))
            {
                controller.AddInput(JoypadButton.Start);
            }

            // Shoulder buttons
            if (buttons.HasFlag(SnesButtons.L))
            {
                controller.AddInput(JoypadButton.L);
            }
            if (buttons.HasFlag(SnesButtons.R))
            {
                controller.AddInput(JoypadButton.R);
            }

            if (this.checkBoxStrafe.Checked)
            {
                controller.AddInput(JoypadButton.R);
            }

            ClientApi.SetInput(1, controller);
        }
Exemplo n.º 5
0
 public ButtonPress(int frames, SnesButtons buttons)
 {
     this.Frames  = frames;
     this.Buttons = buttons;
 }