Beispiel #1
0
        public ProgramItemControl()
        {
            InitializeComponent();
            if (ControlsHelper.IsDesignMode(this))
            {
                return;
            }
            DInputCheckBoxes  = ControlsHelper.GetAll <CheckBox>(DInputMaskGroupBox);
            XInputCheckBoxes  = ControlsHelper.GetAll <CheckBox>(XInputMaskGroupBox);
            HookCheckBoxes    = ControlsHelper.GetAll <CheckBox>(HookMaskGroupBox);
            AutoMapCheckBoxes = ControlsHelper.GetAll <CheckBox>(AutoMapMaskGroupBox);
            // Fill architecture combo box.
            var paItems = (ProcessorArchitecture[])Enum.GetValues(typeof(ProcessorArchitecture));

            foreach (var item in paItems)
            {
                ProcessorArchitectureComboBox.Items.Add(item);
            }
            // Fill emulation type combo box.
            var etItems = (EmulationType[])Enum.GetValues(typeof(EmulationType));

            foreach (var item in etItems)
            {
                EmulationTypeComboBox.Items.Add(item);
            }
            lock (CurrentGameLock)
            {
                EnableEvents();
            }
        }
Beispiel #2
0
        void UpdateControlFromXInput()
        {
            var i           = (int)MappedTo - 1;
            var useXiStates = SettingsManager.Options.GetXInputStates;

            newState = useXiStates
                                ? Global.DHelper.LiveXiStates[i]
                                : Global.DHelper.CombinedXiStates[i];
            newConnected = useXiStates
                                ? Global.DHelper.LiveXiConnected[i]
                                : Global.DHelper.CombinedXiConencted[i];
            // If device is not connected and was not connected then return.
            if (!newConnected && !oldConnected)
            {
                return;
            }
            // If device disconnected then show disabled images.
            if (!newConnected && oldConnected)
            {
                _Imager.SetImages(false);
                GeneralPanel.RemapAllButton.IsEnabled = false;
            }
            // If device connected then show enabled images.
            if (newConnected && !oldConnected)
            {
                _Imager.SetImages(true);
                GeneralPanel.RemapAllButton.IsEnabled = true;
            }
            // Return if controller is not connected.
            if (newConnected)
            {
                //_Imager.DrawController(e, MappedTo);
                // Process all buttons and axis.
                foreach (var ii in imageInfos)
                {
                    _Imager.DrawState(ii, newState.Gamepad);
                }
            }
            // Set values.
            ControlsHelper.SetText(GeneralPanel.LeftTextBox, "{0}", newState.Gamepad.LeftTrigger);
            ControlsHelper.SetText(GeneralPanel.RightTextBox, "{0}", newState.Gamepad.RightTrigger);
            ControlsHelper.SetText(GeneralPanel.LeftThumbTextBox, "{0}:{1}", newState.Gamepad.LeftThumbX, newState.Gamepad.LeftThumbY);
            ControlsHelper.SetText(GeneralPanel.RightThumbTextBox, "{0}:{1}", newState.Gamepad.RightThumbX, newState.Gamepad.RightThumbY);
            // Process device.
            var ud = CurrentUserDevice;

            if (ud != null && ud.DiState != null)
            {
                // Get current pad setting.
                var ps = CurrentPadSetting;
                Map map;
                // LeftThumbX
                var axis = ud.DiState.Axis;
                map = ps.Maps.FirstOrDefault(x => x.Target == TargetType.LeftThumbX);
                if (map != null && map.Index > 0 && map.Index <= axis.Length)
                {
                    LeftThumbXPanel.DrawPoint(axis[map.Index - 1], newState.Gamepad.LeftThumbX, map.IsInverted, map.IsHalf);
                }
                // LeftThumbY
                map = ps.Maps.FirstOrDefault(x => x.Target == TargetType.LeftThumbY);
                if (map != null && map.Index > 0 && map.Index <= axis.Length)
                {
                    LeftThumbYPanel.DrawPoint(axis[map.Index - 1], newState.Gamepad.LeftThumbY, map.IsInverted, map.IsHalf);
                }
                // RightThumbX
                map = ps.Maps.FirstOrDefault(x => x.Target == TargetType.RightThumbX);
                if (map != null && map.Index > 0 && map.Index <= axis.Length)
                {
                    RightThumbXPanel.DrawPoint(axis[map.Index - 1], newState.Gamepad.RightThumbX, map.IsInverted, map.IsHalf);
                }
                // RightThumbY
                map = ps.Maps.FirstOrDefault(x => x.Target == TargetType.RightThumbY);
                if (map != null && map.Index > 0 && map.Index <= axis.Length)
                {
                    RightThumbYPanel.DrawPoint(axis[map.Index - 1], newState.Gamepad.RightThumbY, map.IsInverted, map.IsHalf);
                }
                // LeftTrigger
                map = ps.Maps.FirstOrDefault(x => x.Target == TargetType.LeftTrigger);
                if (map != null && map.Index > 0 && map.Index <= axis.Length)
                {
                    LeftTriggerPanel.DrawPoint(axis[map.Index - 1], newState.Gamepad.LeftTrigger, map.IsInverted, map.IsHalf);
                }
                // RightTrigger
                map = ps.Maps.FirstOrDefault(x => x.Target == TargetType.RightTrigger);
                if (map != null && map.Index > 0 && map.Index <= axis.Length)
                {
                    RightTriggerPanel.DrawPoint(axis[map.Index - 1], newState.Gamepad.RightTrigger, map.IsInverted, map.IsHalf);
                }
            }
            // Update Axis to Button Images.
            if (_AxisToButtonControls == null)
            {
                _AxisToButtonControls = ControlsHelper.GetAll <AxisToButtonControl>(ButtonsPanel.MainGroupBox);
            }
            foreach (var atbPanel in _AxisToButtonControls)
            {
                atbPanel.Refresh(newState);
            }
            // Store old state.
            oldConnected = newConnected;
        }