Beispiel #1
0
        /// <summary>
        /// Event handler:
        /// Attempts to set a new range
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSetRanges_Click(object sender, EventArgs e)
        {
            DataClasses.AxesRange dc = new DataClasses.AxesRange();
            try
            {
                dc.minimum = Convert.ToInt32(tboxAxisMin.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Invalid minimum axes range.", FFBInspector.Properties.Resources.errCap_invalData,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                dc.maximum = Convert.ToInt32(tboxAxisMax.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Invalid maximum axes range.", FFBInspector.Properties.Resources.errCap_invalData,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                GetDInputHandler().SetAxisRange(dc);
            }
            catch (NullReferenceException)
            {
                return;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets range of axes values reported by DirectInput.
        /// </summary>
        /// <param name="s">
        /// Range to be set.
        /// </param>
        /// <returns>
        /// Returns true if successful, otherwise returns false.
        /// </returns>
        public bool SetAxisRange(DataClasses.AxesRange s)
        {
            if (ffbDevice == null)
            {
                return(false);
            }

            PauseAllEffects();
            ffbDevice.Unacquire();
            ffbDevice.Properties.SetRange(s.minimum, s.maximum);

            if (!DisableAutoCenter())
            {
                return(false);
            }

            SlimDX.Result res = ffbDevice.Acquire();
            if (!(res != ResultCode.Success || res != ResultCode.Failure))
            {
                MessageBox.Show("Cannot reacquire the device.\n" +
                                "Make sure no other application is using the device\n" +
                                res.ToString(), FFBInspector.Properties.Resources.errCap_devError,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            ResumeAllEffects();
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// Event handler:
        /// Attempts to set a new range 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSetRanges_Click(object sender, EventArgs e)
        {
            DataClasses.AxesRange dc = new DataClasses.AxesRange();
            try
            {
                dc.minimum = Convert.ToInt32(tboxAxisMin.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Invalid minimum axes range.", FFBInspector.Properties.Resources.errCap_invalData,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                dc.maximum = Convert.ToInt32(tboxAxisMax.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Invalid maximum axes range.", FFBInspector.Properties.Resources.errCap_invalData,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                GetDInputHandler().SetAxisRange(dc);
            }
            catch (NullReferenceException)
            {
                return;
            }
        }