public unsafe DirectInputForceFeedbackController(IDirectInputDevice8 *directInputDevice, JoystickInputDevice joystick) : base(joystick) { int hr = IDirectInputDevice8.EnumEffects(directInputDevice, EnumEffectHandler, null, DInput.DIEFT_ALL); if (Wrapper.FAILED(hr)) { Log.Warning("DirectInputForceFeedbackController: " + "Cannot enum ForceFeedbackEffects for \"{0}\" ({1}).", Device.Name, DInput.GetOutString(DInput.DXGetErrorStringW(hr))); } }
void devicesComboBox_SelectedIndexChange( ComboBox sender ) { selectedJoystick = sender.SelectedItem as JoystickInputDevice; //update TestEffectType combo box { ComboBox typeComboBox = (ComboBox)PageControl.Controls[ "TestEffectType" ]; typeComboBox.Items.Clear(); if( selectedJoystick != null && selectedJoystick.ForceFeedbackController != null ) { int typeCount = Enum.GetValues( typeof( ForceFeedbackEffectTypes ) ).Length; for( int n = 0; n < typeCount; n++ ) { ForceFeedbackEffectTypes effectType = (ForceFeedbackEffectTypes)n; if( selectedJoystick.ForceFeedbackController.IsEffectSupported( effectType ) ) { typeComboBox.Items.Add( effectType ); if( effectType == ForceFeedbackEffectTypes.ConstantForce ) typeComboBox.SelectedIndex = typeComboBox.Items.Count - 1; } } } if( typeComboBox.Items.Count > 0 && typeComboBox.SelectedIndex == -1 ) typeComboBox.SelectedIndex = 0; } //update TestEffectAxis combo box { ComboBox axisComboBox = (ComboBox)PageControl.Controls[ "TestEffectAxis" ]; axisComboBox.Items.Clear(); if( selectedJoystick != null && selectedJoystick.ForceFeedbackController != null ) { bool existsX = false; bool existsY = false; for( int n = 0; n < selectedJoystick.Axes.Length; n++ ) { JoystickInputDevice.Axis axis = selectedJoystick.Axes[ n ]; axisComboBox.Items.Add( new TestEffectAxisItem( new JoystickAxes[] { axis.Name } ) ); if( axis.Name == JoystickAxes.X ) existsX = true; if( axis.Name == JoystickAxes.Y ) existsY = true; } if( existsX && existsY ) { axisComboBox.Items.Add( new TestEffectAxisItem( new JoystickAxes[] { JoystickAxes.X, JoystickAxes.Y } ) ); axisComboBox.SelectedIndex = axisComboBox.Items.Count - 1; } } if( axisComboBox.Items.Count > 0 && axisComboBox.SelectedIndex == -1 ) axisComboBox.SelectedIndex = 0; } }
void UpdateBindedInputControlsTextBox() { Control pageControls = window.Controls["TabControl"].Controls["Controls"]; InputDevice inputDevice = comboBoxInputDevices.SelectedItem as InputDevice; string text = ""; foreach (GameControlsManager.GameControlItem item in GameControlsManager.Instance.Items) { string valueStr = ""; //keys and mouse buttons if (inputDevice == null) { foreach (GameControlsManager.SystemKeyboardMouseValue value in item.DefaultKeyboardMouseValues) { if (valueStr != "") { valueStr += ", "; } switch (value.Type) { case GameControlsManager.SystemKeyboardMouseValue.Types.Key: valueStr += string.Format("\"{0}\" key", value.Key); break; case GameControlsManager.SystemKeyboardMouseValue.Types.MouseButton: valueStr += string.Format("\"{0}\" mouse button", value.MouseButton); break; } } } //joystick JoystickInputDevice joystickInputDevice = inputDevice as JoystickInputDevice; if (joystickInputDevice != null) { foreach (GameControlsManager.SystemJoystickValue value in item.DefaultJoystickValues) { if (valueStr != "") { valueStr += ", "; } switch (value.Type) { case GameControlsManager.SystemJoystickValue.Types.Button: if (joystickInputDevice.GetButtonByName(value.Button) != null) { valueStr += string.Format("\"{0}\"", value.Button); } break; case GameControlsManager.SystemJoystickValue.Types.Axis: if (joystickInputDevice.GetAxisByName(value.Axis) != null) { valueStr += string.Format("axis \"{0} {1}\"", value.Axis, value.AxisFilter); } break; case GameControlsManager.SystemJoystickValue.Types.POV: if (joystickInputDevice.GetPOVByName(value.POV) != null) { valueStr += string.Format("\"{0} {1}\"", value.POV, value.POVDirection); } break; } } } if (valueStr != "") { text += string.Format("{0} - {1}\n", item.ControlKey.ToString(), valueStr); } } pageControls.Controls["Controls"].Text = text; }
void UpdateBindedInputControlsTextBox() { Control pageControls = window.Controls["TabControl"].Controls["Controls"]; //!!!!temp string text = "Configuring of custom controls is not implemented\n"; text += "\n"; InputDevice inputDevice = comboBoxInputDevices.SelectedItem as InputDevice; text += "Binded keys:\n\n"; foreach (GameControlsManager.GameControlItem item in GameControlsManager.Instance.Items) { string valueStr = ""; //keys and mouse buttons if (inputDevice == null) { foreach (GameControlsManager.SystemKeyboardMouseValue value in item.DefaultKeyboardMouseValues) { switch (value.Type) { case GameControlsManager.SystemKeyboardMouseValue.Types.Key: valueStr += string.Format("Key: {0}", value.Key); break; case GameControlsManager.SystemKeyboardMouseValue.Types.MouseButton: valueStr += string.Format("MouseButton: {0}", value.MouseButton); break; } } } //joystick JoystickInputDevice joystickInputDevice = inputDevice as JoystickInputDevice; if (joystickInputDevice != null) { foreach (GameControlsManager.SystemJoystickValue value in item.DefaultJoystickValues) { switch (value.Type) { case GameControlsManager.SystemJoystickValue.Types.Button: if (joystickInputDevice.GetButtonByName(value.Button) != null) { valueStr += string.Format("Button: {0}", value.Button); } break; case GameControlsManager.SystemJoystickValue.Types.Axis: if (joystickInputDevice.GetAxisByName(value.Axis) != null) { valueStr += string.Format("Axis: {0}({1})", value.Axis, value.AxisFilter); } break; case GameControlsManager.SystemJoystickValue.Types.POV: if (joystickInputDevice.GetPOVByName(value.POV) != null) { valueStr += string.Format("POV: {0}({1})", value.POV, value.POVDirection); } break; } } } if (valueStr != "") { text += string.Format("{0} - {1}\n", item.ControlKey.ToString(), valueStr); } } pageControls.Controls["Controls"].Text = text; }
public static bool Setup() { if (requiresSetup) { requiresSetup = false; JoystickInput deskCtrl, g25Wheel, ps4Ctrl; // Joysticks var dskObj = JoystickInputDevice.Search("Hotas").FirstOrDefault(); deskCtrl = dskObj == null ? default(JoystickInput) : new JoystickInput(dskObj); var ps4Obj = JoystickInputDevice.Search("Wireless Controller").FirstOrDefault(); ps4Ctrl = ps4Obj == null ? default(JoystickInput) : new JoystickInput(ps4Obj); var g25Obj = JoystickInputDevice.Search("G25").FirstOrDefault(); g25Wheel = g25Obj == null ? default(JoystickInput) : new JoystickInput(g25Obj); var vJoy = new JoystickOutput(); // add main controller: if (dskCtlActive) { RawJoysticksIn.Add(deskCtrl); } else if (ps4CtlActive) { RawJoysticksIn.Add(ps4Ctrl); } else { RawJoysticksIn.Add(default(JoystickInput)); } RawJoysticksIn.Add(g25Wheel); RawJoysticksOut.Add(vJoy); // Data source Data = new DataArbiter(); Data.CarChanged += (s, e) => { if (Data.Active.Application == "eurotrucks2") { Drivetrain = new Ets2Drivetrain(); } else { Drivetrain = new GenericDrivetrain(); } // reset all modules Antistall.ResetParameters(); CruiseControl.ResetParameters(); Drivetrain.ResetParameters(); Transmission.ResetParameters(); TractionControl.ResetParameters(); Speedlimiter.ResetParameters(); CarProfile = new Profiles(Data.Active.Application, Data.Telemetry.Car); LoadNextProfile(10000); }; // TODO: Temporary.. Data.AppActive += (s, e) => { CameraHorizon.CameraHackEnabled = Data.Active.Application == "TestDrive2"; }; if (deskCtrl == null && g25Wheel == null && ps4Ctrl == null) { //MessageBox.Show("No controllers found"); return(false); } // Modules Antistall = new Antistall(); ACC = new ACC(); CruiseControl = new CruiseControl(); Drivetrain = new GenericDrivetrain(); Transmission = new Transmission(); TractionControl = new TractionControl(); ProfileSwitcher = new ProfileSwitcher(); Speedlimiter = new Speedlimiter(); LaunchControl = new LaunchControl(); DrivetrainCalibrator = new DrivetrainCalibrator(); TransmissionCalibrator = new TransmissionCalibrator(); LaneAssistance = new LaneAssistance(); VariableSpeedControl = new VariableSpeedTransmission(); CameraHorizon = new CameraHorizon(); // Controls Controls = new ControlChain(); Data.Run(); return(true); } return(false); }