Ejemplo n.º 1
0
        private void ControllerMap_Load(object sender, EventArgs e)
        {
            this.controller.Connect();
            this.controller.Disconnect();
            this.CapbsTextBox.Text = $"Buttons:{this.controller.ButtonCount}\n" +
                                     string.Join("\n", this.controller.Capabilities.Select(x => x.ToString()));
            foreach (JoystickCapabilities cap in this.controller.Capabilities)
            {
                SettingPanel newPanel = new SettingPanel(
                    AxisSettingComboBox_SelectedIndexChanged,
                    cap.ToString(),
                    (cb) => {
                    cb.data = cap;
                    cb.Items.AddRange(ControllerCache.vc.Capabilities.Select(x => x.ToString()).ToArray());

                    AxisMap aMap = this.controller.Mappings
                                   .OfType <AxisMap>()
                                   .Where(x => x.inAxis == cap)
                                   .DefaultIfEmpty(null)
                                   .FirstOrDefault();
                    if (aMap != null)
                    {
                        cb.SelectedItem = aMap.outAxis.ToString();
                    }
                });
                this.panels.Add(newPanel);
                this.AxisGroup.Controls.Add(newPanel.Setting);
            }

            // int x in (this.controller as GameController).FFBAxes
            if ((this.controller as GameController).FFBAxes != null && (this.controller as GameController).FFBAxes.Length > 0)
            {
                foreach (int vcAxis in ControllerCache.vc.FFBAxes)
                {
                    // axisN - axis on VC to get FFB
                    SettingPanel newPanel = new SettingPanel(
                        FFBSettingComboBox_SelectedIndexChanged,
                        $"VCAxis={vcAxis}",
                        (cb) => {
                        cb.data = vcAxis;

                        // axis on GC to send FFB
                        cb.Items.AddRange((this.controller as GameController).FFBAxes.Select(f => f.ToString()).ToArray());

                        FFBMap aMap = this.controller.Mappings
                                      .OfType <FFBMap>()
                                      .Where(x => x.vcAxis == vcAxis)
                                      .DefaultIfEmpty(null)
                                      .FirstOrDefault();
                        if (aMap != null)
                        {
                            cb.SelectedItem = aMap.gcAxis.ToString();
                        }
                    });
                    this.panels.Add(newPanel);
                    this.FFBGroup.Controls.Add(newPanel.Setting);
                }
            }
        }
Ejemplo n.º 2
0
        private void FFBSettingComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExtendedComboBox SettingComboBox = sender as ExtendedComboBox;
            int    vcAxis = (int)SettingComboBox.data;
            int    gcAxis = int.Parse(SettingComboBox.SelectedItem as string);
            FFBMap aMap   = this.controller.Mappings
                            .OfType <FFBMap>()
                            .Where(x => x.gcAxis == vcAxis)
                            .DefaultIfEmpty(null)
                            .FirstOrDefault();

            if (aMap != null)
            {
                aMap.SetGC(gcAxis);
            }
            else
            {
                this.controller.Mappings.Add(new FFBMap(this.controller as GameController, vcAxis, gcAxis));
            }
        }