private void CalibrateTrigger_Click(object sender, RoutedEventArgs e) { _calibrationTarget = (sender as FrameworkElement).Tag.ToString(); var nonCalibrated = new NintrollerLib.Trigger(); var curCalibrated = new NintrollerLib.Trigger(); if (_calibrationTarget == App.CAL_CC_RTRIGGER) { nonCalibrated = Calibrations.None.ClassicControllerRaw.R; curCalibrated = ((ClassicController)_lastState).R; } else if (_calibrationTarget == App.CAL_CC_LTRIGGER) { nonCalibrated = Calibrations.None.ClassicControllerRaw.L; curCalibrated = ((ClassicController)_lastState).L; } else if (_calibrationTarget == App.CAL_GUT_WHAMMY) { nonCalibrated = Calibrations.None.GuitarRaw.whammyBar; curCalibrated = ((Guitar)_lastState).whammyBar; } else { return; } Windows.TriggerCalibrationWindow trigCal = new Windows.TriggerCalibrationWindow(nonCalibrated, curCalibrated); _openTrigWindow = trigCal; #if DEBUG if (DeviceID.StartsWith("Dummy")) { trigCal.Closed += (obj, args) => { if (trigCal.Apply) { OnTriggerCalibrated?.Invoke(trigCal.Calibration, _calibrationTarget, trigCal.FileName); } _openTrigWindow = null; }; trigCal.Show(); return; } #endif trigCal.ShowDialog(); if (trigCal.Apply) { OnTriggerCalibrated?.Invoke(trigCal.Calibration, _calibrationTarget, trigCal.FileName); } _openTrigWindow = null; }
private void CalibrateTrigger(bool rightTrigger) { GameCubeController controller; GetActivePort(out controller); var nonCalibrated = new NintrollerLib.Trigger(); var curCalibrated = new NintrollerLib.Trigger(); if (rightTrigger) { _calibrationTarget = "R"; nonCalibrated = Calibrations.None.GameCubeControllerRaw.R; curCalibrated = controller.R; } else { _calibrationTarget = "L"; nonCalibrated = Calibrations.None.GameCubeControllerRaw.L; curCalibrated = controller.L; } Windows.TriggerCalibrationWindow trigCal = new Windows.TriggerCalibrationWindow(nonCalibrated, curCalibrated); _openTrigWindow = trigCal; #if DEBUG // Don't use show dialog so dummy values can be modified if (DeviceID?.StartsWith("Dummy") ?? false) { trigCal.Closed += (obj, args) => { if (trigCal.Apply) { OnTriggerCalibrated?.Invoke(trigCal.Calibration, _calibrationTarget, trigCal.FileName); } _openTrigWindow = null; }; trigCal.Show(); return; } #endif trigCal.ShowDialog(); if (trigCal.Apply) { OnTriggerCalibrated?.Invoke(trigCal.Calibration, _calibrationTarget, trigCal.FileName); } _openTrigWindow = null; trigCal = null; }
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; }
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; }
public AddSensorViewModel(Router router, ThingsDeviceModel showModel = null) { _router = router; _showModel = showModel; if (_showModel != null) { DeviceID = showModel.DeviceId; DeviceEUI = showModel.Device.DeviceEUI; Description = showModel.Description; AppKey = showModel.AppId; AppEUI = showModel.Device.AppEUI; } AddDevice = ReactiveCommand.Create(() => { }); AddDevice.Subscribe(async unit => { try { if (!DeviceID.StartsWith(ThingsNetworkDevicesApi.HackathonDeviceIdPrefix)) { throw new Exception("Device ID must start with " + ThingsNetworkDevicesApi.HackathonDeviceIdPrefix); } var device = new ThingsDeviceModel { AppId = ThingsNetworkDevicesApi.app_id, Description = Description, DeviceId = DeviceID.Trim().ToLower(), Device = new ThingsDeviceLorawan { DeviceId = DeviceID, AppId = ThingsNetworkDevicesApi.app_id, DeviceEUI = DeviceEUI, AppEUI = AppEUI } }; await ThingsNetworkDevicesApi.AddDevice(device); _onDeviceAdded.OnNext(device); _router.ShowDevices(); } catch (Exception err) { _onError.OnNext(err); } }).DisposeWith(_disposable); DeleteDevice = ReactiveCommand.Create(() => { }); DeleteDevice.Subscribe(async unit => { try { await ThingsNetworkDevicesApi.DeleteDevice(DeviceID); Beep(); _router.ShowDevices(); } catch (Exception err) { Beep(2); _onError.OnNext(err); } }).DisposeWith(_disposable); Clear = ReactiveCommand.Create(() => { }); Clear.Subscribe(unit => { DeviceID = ThingsNetworkDevicesApi.HackathonDeviceIdPrefix; DeviceEUI = Utils.RandomByteString(8); }).DisposeWith(_disposable); Cancel = ReactiveCommand.Create(() => { }); Cancel.Subscribe(_ => _router.ShowDevices()).DisposeWith(_disposable); }
private void CalibrateJoystick_Click(object sender, RoutedEventArgs e) { _calibrationTarget = (sender as FrameworkElement).Tag.ToString(); Joystick nonCalibrated = new Joystick(); Joystick curCalibration = new Joystick(); switch (_calibrationTarget) { case App.CAL_NUN_JOYSTICK: nonCalibrated = Calibrations.None.NunchukRaw.joystick; if (_lastState is Nunchuk) { curCalibration = ((Nunchuk)_lastState).joystick; } break; case App.CAL_CC_LJOYSTICK: nonCalibrated = Calibrations.None.ClassicControllerRaw.LJoy; if (_lastState is ClassicController) { curCalibration = ((ClassicController)_lastState).LJoy; } break; case App.CAL_CC_RJOYSTICK: nonCalibrated = Calibrations.None.ClassicControllerRaw.RJoy; if (_lastState is ClassicController) { curCalibration = ((ClassicController)_lastState).RJoy; } break; case App.CAL_CCP_LJOYSTICK: nonCalibrated = Calibrations.None.ClassicControllerProRaw.LJoy; if (_lastState is ClassicControllerPro) { curCalibration = ((ClassicControllerPro)_lastState).LJoy; } break; case App.CAL_CCP_RJOYSTICK: nonCalibrated = Calibrations.None.ClassicControllerProRaw.RJoy; if (_lastState is ClassicControllerPro) { curCalibration = ((ClassicControllerPro)_lastState).RJoy; } break; case App.CAL_GUT_JOYSTICK: nonCalibrated = Calibrations.None.GuitarRaw.joystick; if (_lastState is Guitar) { curCalibration = ((Guitar)_lastState).joystick; } break; default: return; } Windows.JoyCalibrationWindow joyCal = new Windows.JoyCalibrationWindow(nonCalibrated, curCalibration); _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) { OnJoystickCalibrated?.Invoke(joyCal.Calibration, _calibrationTarget, joyCal.FileName); } _openJoyWindow = null; }; joyCal.Show(); return; } #endif joyCal.ShowDialog(); if (joyCal.Apply) { OnJoystickCalibrated?.Invoke(joyCal.Calibration, _calibrationTarget, joyCal.FileName); } _openJoyWindow = null; }