コード例 #1
0
        private void frmJoystickConfig_Load(object sender, EventArgs e)
        {
            ButtonGrid.Rows.Add(36);    // 32 buttons and 4 POV directions
            ButtonGrid.RowHeadersVisible = false;

            string [] dir = new string[] { "Up", "Down", "Left", "Right" };

            ButtonGrid.DataError += new DataGridViewDataErrorEventHandler(ButtonGrid_DataError);
            for (int i = 0; i < 36; ++i)
            {
                DataGridViewTextBoxCell txt = ((DataGridViewTextBoxCell)ButtonGrid.Rows[i].Cells[0]);
                if (i >= 32)
                {
                    txt.Value = "POV " + dir[i - 32];

                } else 
                    txt.Value = "Button " + (i + 1).ToString();

                txt.Style.BackColor = Color.Black;
                txt.Style.ForeColor = Color.LightGray;
                //txt.Frozen = true;
                txt.ReadOnly = true;

                DataGridViewComboBoxCell cmb = ((DataGridViewComboBoxCell)ButtonGrid.Rows[i].Cells[1]);
                cmb.DisplayMember = "Display";
                cmb.ValueMember = "Self";

                cmb.FlatStyle = FlatStyle.Flat;
                cmb.Sorted = false;
                cmb.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                cmb.Style.BackColor = Color.Black;
                cmb.Style.ForeColor = Color.LightGray;
                cmb.DisplayStyleForCurrentCellOnly = true;
                
                foreach (AssignmentClass asc in AllAssignments)
                {
                    int idx = cmb.Items.Add(asc);
                }
            }


            if (!string.IsNullOrEmpty(JoystickName))
            {
                if (!m_JS.Initialize(JoystickName, GeminiHardware.Instance.JoystickAxisRA, GeminiHardware.Instance.JoystickAxisDEC))
                    m_JS = null;
                else
                {
                    tmrJoystick.Tick += new EventHandler(tmrJoystick_Tick);
                    tmrJoystick.Interval = 200;
                    tmrJoystick.Start();

                    int axis = m_JS.NumberOfAxis;
                    for (int i = 0; i < axis; i++)
                    {
                        cmbAxisRA.Items.Add("Axis " + (i + 1).ToString() );
                        cmbAxisDEC.Items.Add("Axis " + (i + 1).ToString());
                    }

//                    if (m_JS.HasPOV4)
//                        cmbAxis.Items.Add("POV 4-way Controller");

                    // default to axis 0 and 1 (X & Y):
                    if (cmbAxisRA.Items.Count > 0)
                        cmbAxisRA.SelectedIndex = 0;

                    if (cmbAxisDEC.Items.Count > 1)
                        cmbAxisDEC.SelectedIndex = 1;

                }
            }

            PersistProfile(false);  // load all settings from profile
        }
コード例 #2
0
        private void StartJoystick()
        {
            m_JoystickRate = null;
            m_JoystickRate = null;

            int[] joys = Joystick.Joysticks;
            if (joys != null && joys.Length > 0)
            {
                if (!string.IsNullOrEmpty(GeminiHardware.Instance.JoystickName))
                {
                    m_Joystick = new Joystick();
                    if (m_Joystick.Initialize(GeminiHardware.Instance.JoystickName, GeminiHardware.Instance.JoystickAxisRA, GeminiHardware.Instance.JoystickAxisDEC))
                    {
                        tmrJoystick.Interval = 200;
                        tmrJoystick.Start();
                    }
                    else
                        SetBaloonText(SharedResources.TELESCOPE_DRIVER_NAME, Resources.JoystickIsNotAvailable + "\r\n" + GeminiHardware.Instance.JoystickName, ToolTipIcon.Warning);
                }
            }
        }