Exemplo n.º 1
0
        private void Calibrate_Click(object sender, RoutedEventArgs e)
        {
            _rightJoyOpen = (sender as FrameworkElement).Tag.Equals("JoyR");
            string joyTarget = _rightJoyOpen ? App.CAL_PRO_RJOYSTICK : App.CAL_PRO_LJOYSTICK;

            var    info     = ObtainDeviceInfoDel();
            var    prefs    = AppPrefs.Instance.GetDevicePreferences(info.DevicePath);
            string filename = "";

            prefs?.calibrationFiles.TryGetValue(joyTarget, out filename);

            Windows.JoyCalibrationWindow joyCal = new Windows.JoyCalibrationWindow(
                _rightJoyOpen ? Calibrations.None.ProControllerRaw.RJoy : Calibrations.None.ProControllerRaw.LJoy,
                _rightJoyOpen ? _lastState.RJoy : _lastState.LJoy,
                filename ?? "");
            _openJoyWindow = joyCal;
            joyCal.ShowDialog();

            if (joyCal.Apply)
            {
                OnJoyCalibrated?.Invoke(joyCal.Calibration, joyTarget, joyCal.FileName);
            }

            _openJoyWindow = null;
            joyCal         = null;
        }
Exemplo n.º 2
0
        private void CalibrateJoystick(bool cStick)
        {
            GameCubeController controller;

            GetActivePort(out controller);

            var nonCalibrated = new NintrollerLib.Joystick();
            var curCalibrated = new NintrollerLib.Joystick();

            if (cStick)
            {
                _calibrationTarget = "cStk";
                nonCalibrated      = Calibrations.None.GameCubeControllerRaw.cStick;
                curCalibrated      = controller.cStick;
            }
            else
            {
                _calibrationTarget = "joy";
                nonCalibrated      = Calibrations.None.GameCubeControllerRaw.joystick;
                curCalibrated      = controller.joystick;
            }

            Windows.JoyCalibrationWindow joyCal = new Windows.JoyCalibrationWindow(nonCalibrated, curCalibrated);
            _openJoyWindow = joyCal;

#if DEBUG
            // Don't use show dialog so dummy values can be modified
            if (DeviceID?.StartsWith("Dummy") ?? false)
            {
                joyCal.Closed += (obj, args) =>
                {
                    if (joyCal.Apply)
                    {
                        OnJoyCalibrated?.Invoke(joyCal.Calibration, _calibrationTarget, joyCal.FileName);
                    }
                    _openJoyWindow = null;
                };

                joyCal.Show();
                return;
            }
#endif

            joyCal.ShowDialog();

            if (joyCal.Apply)
            {
                OnJoyCalibrated?.Invoke(joyCal.Calibration, _calibrationTarget, joyCal.FileName);
            }

            _openJoyWindow = null;
            joyCal         = null;
        }
Exemplo n.º 3
0
        protected override void CalibrateInput(string inputName)
        {
            _rightJoyOpen = inputName == "proR";

            string joyTarget = _rightJoyOpen ? App.CAL_PRO_RJOYSTICK : App.CAL_PRO_LJOYSTICK;

            var    prefs    = AppPrefs.Instance.GetDevicePreferences(DeviceID);
            string filename = "";

            prefs?.calibrationFiles.TryGetValue(joyTarget, out filename);

            Windows.JoyCalibrationWindow joyCal = new Windows.JoyCalibrationWindow(
                _rightJoyOpen ? Calibrations.None.ProControllerRaw.RJoy : Calibrations.None.ProControllerRaw.LJoy,
                _rightJoyOpen ? _lastState.RJoy : _lastState.LJoy,
                filename ?? "");
            _openJoyWindow = joyCal;

#if DEBUG
            // This will allow for the dummy device window to retain focus
            if (DeviceID.StartsWith("Dummy"))
            {
                joyCal.Closed += (obj, args) =>
                {
                    if (joyCal.Apply)
                    {
                        OnJoyCalibrated?.Invoke(joyCal.Calibration, joyTarget, joyCal.FileName);
                    }

                    _openJoyWindow = null;
                };

                joyCal.Show();
                return;
            }
#endif

            joyCal.ShowDialog();

            if (joyCal.Apply)
            {
                OnJoyCalibrated?.Invoke(joyCal.Calibration, joyTarget, joyCal.FileName);
            }

            _openJoyWindow = null;
            joyCal         = null;
        }