Exemple #1
0
        public FormKey(SlimDX.DirectInput.DeviceType type, string deviceGuid, string keyName)
        {
            this.deviceType = type;
            InitializeComponent();

            DirectInput di = new DirectInput();

            switch (type)
            {
            case SlimDX.DirectInput.DeviceType.Keyboard:
            {
                keyboard = new Keyboard(di);
                keyboard.SetCooperativeLevel(this.Handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground);
                break;
            }

            case SlimDX.DirectInput.DeviceType.Joystick:
            {
                joystick = new Joystick(di, Guid.Parse(deviceGuid));
                joystick.SetCooperativeLevel(this.Handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground);

                break;
            }

            case SlimDX.DirectInput.DeviceType.Other:
            {
                switch (deviceGuid)
                {
                case "x-controller-1": x_controller = new Controller(UserIndex.One); break;

                case "x-controller-2": x_controller = new Controller(UserIndex.Two); break;

                case "x-controller-3": x_controller = new Controller(UserIndex.Three); break;

                case "x-controller-4": x_controller = new Controller(UserIndex.Four); break;
                }
                break;
            }
            }

            timer_hold.Start();
            label1.Text       = string.Format(Program.ResourceManager.GetString("Text_PressAKeyFor") + " [{0}]", keyName);
            stopTimer         = 10;
            label_cancel.Text = string.Format(Program.ResourceManager.GetString("Status_CancelIn") + " {0} " +
                                              Program.ResourceManager.GetString("Status_Seconds"), stopTimer);
            timer2.Start();
            this.Select();
        }
Exemple #2
0
        public FormKey(SlimDX.DirectInput.DeviceType type, string deviceGuid, string keyName)
        {
            this.deviceType = type;
            InitializeComponent();

            DirectInput di = new DirectInput();

            switch (type)
            {
                case SlimDX.DirectInput.DeviceType.Keyboard:
                    {
                        keyboard = new Keyboard(di);
                        keyboard.SetCooperativeLevel(this.Handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground);
                        break;
                    }
                case SlimDX.DirectInput.DeviceType.Joystick:
                    {
                        joystick = new Joystick(di, Guid.Parse(deviceGuid));
                        joystick.SetCooperativeLevel(this.Handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground);

                        break;
                    }
                case SlimDX.DirectInput.DeviceType.Other:
                    {
                        switch (deviceGuid)
                        {
                            case "x-controller-1": x_controller = new Controller(UserIndex.One); break;
                            case "x-controller-2": x_controller = new Controller(UserIndex.Two); break;
                            case "x-controller-3": x_controller = new Controller(UserIndex.Three); break;
                            case "x-controller-4": x_controller = new Controller(UserIndex.Four); break;
                        }
                        break;
                    }
            }

            timer_hold.Start();
            label1.Text = string.Format(Program.ResourceManager.GetString("Text_PressAKeyFor") + " [{0}]", keyName);
            stopTimer = 10;
            label_cancel.Text = string.Format(Program.ResourceManager.GetString("Status_CancelIn") + " {0} " +
                Program.ResourceManager.GetString("Status_Seconds"), stopTimer);
            timer2.Start();
            this.Select();
        }