public static DirectXControllerFunction Create(DirectXControllerInterface controllerInterface, Guid objectType, int objectNumber, JoystickState initialState) { DirectXControllerFunction function = null; if (objectType == ObjectGuid.Button) function = new DirectXControllerButton(controllerInterface, objectNumber, initialState); else if (objectType == ObjectGuid.Slider) function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Slider, objectNumber, initialState); else if (objectType == ObjectGuid.XAxis) function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.X, objectNumber, initialState); else if (objectType == ObjectGuid.YAxis) function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Y, objectNumber, initialState); else if (objectType == ObjectGuid.ZAxis) function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Z, objectNumber, initialState); else if (objectType == ObjectGuid.RxAxis) function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Rx, objectNumber, initialState); else if (objectType == ObjectGuid.RyAxis) function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Ry, objectNumber, initialState); else if (objectType == ObjectGuid.RzAxis) function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Rz, objectNumber, initialState); else if (objectType == ObjectGuid.PovController) function = new DirectXControllerPOVHat(controllerInterface, objectNumber, initialState); return function; }
internal List <DirectXControllerGuid> GetAvailableControllers(HeliosProfile profile) { List <DirectXControllerGuid> controllers = new List <DirectXControllerGuid>(); List <DirectXControllerGuid> usedControllers = new List <DirectXControllerGuid>(); foreach (HeliosInterface profileInterface in profile.Interfaces) { DirectXControllerInterface controllerInterface = profileInterface as DirectXControllerInterface; if (controllerInterface != null) { usedControllers.Add(controllerInterface.ControllerId); } } IList <DeviceInstance> gameControllerList = DirectInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly); foreach (DeviceInstance controllerInstance in gameControllerList) { DirectXControllerGuid joystickId = new DirectXControllerGuid(controllerInstance.ProductName, controllerInstance.InstanceGuid); if (!usedControllers.Contains(joystickId)) { controllers.Add(joystickId); } } return(controllers); }
public DirectXControllerAxis(DirectXControllerInterface controllerInterface, AxisType type, int axisNumber, JoystickState initialState) { _axisType = type; _axisNumber = axisNumber; _value = new HeliosValue(controllerInterface, new BindingValue(GetValue(initialState)), "", Name, "Current value for " + Name + ".", "(0 - 65536)", BindingValueUnits.Numeric); _triggers.Add(_value); }
public DirectXControllerAxis(DirectXControllerInterface controllerInterface, AxisType type, int axisNumber, JoystickState initialState) { _axisType = type; _axisNumber = axisNumber; _value = new HeliosValue(controllerInterface, new BindingValue(GetValue(initialState)), "", Name, "Current value for " + Name + ".", "(0 - 65536)", BindingValueUnits.Numeric); _triggers.Add(_value); }
public override List <HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile) { List <HeliosInterface> interfaces = new List <HeliosInterface>(); foreach (DirectXControllerGuid guid in GetAvailableControllers(profile)) { DirectXControllerInterface newInterface = new DirectXControllerInterface(); newInterface.ControllerId = guid; interfaces.Add(newInterface); } return(interfaces); }
public override List<HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile) { List<HeliosInterface> interfaces = new List<HeliosInterface>(); foreach (DirectXControllerGuid guid in GetAvailableControllers(profile)) { DirectXControllerInterface newInterface = new DirectXControllerInterface(); newInterface.ControllerId = guid; interfaces.Add(newInterface); } return interfaces; }
public DirectXControllerPOVHat(DirectXControllerInterface controllerInterface, int povNumber) { _lastPollValue = POVDirection.Center; _povNumber = povNumber; _name = "POV " + (_povNumber + 1); _value = new HeliosValue(controllerInterface, new BindingValue(-1d), "", _name, "Current state for " + _name + ".", "-1 = Centered, 0 = Up, 45 = Up and Right, 90 = Right, 135 = Down and Right, 180 = Down, 225 = Down and Left, 270 = Left, 315 = Up and Left", BindingValueUnits.Boolean); _centerEnter = new HeliosTrigger(controllerInterface, _name, "center", "entered", "Fires when hat enters the center position."); _triggers.Add(_centerEnter); _centerExit = new HeliosTrigger(controllerInterface, _name, "center", "exited", "Fires when the hat leaves the center position."); _triggers.Add(_centerExit); _rightEnter = new HeliosTrigger(controllerInterface, _name, "right", "entered", "Fires when hat enters the right position."); _triggers.Add(_rightEnter); _rightExit = new HeliosTrigger(controllerInterface, _name, "right", "exited", "Fires when the hat leaves the right position."); _triggers.Add(_rightExit); _leftEnter = new HeliosTrigger(controllerInterface, _name, "left", "entered", "Fires when hat enters the left position."); _triggers.Add(_leftEnter); _leftExit = new HeliosTrigger(controllerInterface, _name, "left", "exited", "Fires when the hat leaves the left position."); _triggers.Add(_leftExit); _upEnter = new HeliosTrigger(controllerInterface, _name, "up", "entered", "Fires when hat enters the up position."); _triggers.Add(_upEnter); _upExit = new HeliosTrigger(controllerInterface, _name, "up", "exited", "Fires when the hat leaves the up position."); _triggers.Add(_upExit); _upLeftEnter = new HeliosTrigger(controllerInterface, _name, "up and left", "entered", "Fires when hat enters the upper left position."); _triggers.Add(_upLeftEnter); _upLeftExit = new HeliosTrigger(controllerInterface, _name, "up and left", "exited", "Fires when the hat leaves the upper left position."); _triggers.Add(_upLeftExit); _upRightEnter = new HeliosTrigger(controllerInterface, _name, "up and right", "entered", "Fires when hat enters the upper right position."); _triggers.Add(_upRightEnter); _upRightExit = new HeliosTrigger(controllerInterface, _name, "up and right", "exited", "Fires when the hat leaves the upper right position."); _triggers.Add(_upRightExit); _downEnter = new HeliosTrigger(controllerInterface, _name, "down", "entered", "Fires when hat enters the down position."); _triggers.Add(_downEnter); _downExit = new HeliosTrigger(controllerInterface, _name, "down", "exited", "Fires when the hat leaves the down position."); _triggers.Add(_downExit); _downLeftEnter = new HeliosTrigger(controllerInterface, _name, "down and left", "entered", "Fires when hat enters the downper left position."); _triggers.Add(_downLeftEnter); _downLeftExit = new HeliosTrigger(controllerInterface, _name, "down and left", "exited", "Fires when the hat leaves the downper left position."); _triggers.Add(_downLeftExit); _downRightEnter = new HeliosTrigger(controllerInterface, _name, "down and right", "entered", "Fires when hat enters the downper right position."); _triggers.Add(_downRightEnter); _downRightExit = new HeliosTrigger(controllerInterface, _name, "down and right", "exited", "Fires when the hat leaves the downper right position."); _triggers.Add(_downRightExit); }
public DirectXControllerPOVHat(DirectXControllerInterface controllerInterface, int povNumber) { _lastPollValue = POVDirection.Center; _povNumber = povNumber; _name = "POV " + (_povNumber + 1); _value = new HeliosValue(controllerInterface, new BindingValue(-1d), "", _name, "Current state for " + _name + ".", "-1 = Centered, 0 = Up, 45 = Up and Right, 90 = Right, 135 = Down and Right, 180 = Down, 225 = Down and Left, 270 = Left, 315 = Up and Left", BindingValueUnits.Boolean); _centerEnter = new HeliosTrigger(controllerInterface, _name, "center", "entered", "Fires when hat enters the center position."); _triggers.Add(_centerEnter); _centerExit = new HeliosTrigger(controllerInterface, _name, "center", "exited", "Fires when the hat leaves the center position."); _triggers.Add(_centerExit); _rightEnter = new HeliosTrigger(controllerInterface, _name, "right", "entered", "Fires when hat enters the right position."); _triggers.Add(_rightEnter); _rightExit = new HeliosTrigger(controllerInterface, _name, "right", "exited", "Fires when the hat leaves the right position."); _triggers.Add(_rightExit); _leftEnter = new HeliosTrigger(controllerInterface, _name, "left", "entered", "Fires when hat enters the left position."); _triggers.Add(_leftEnter); _leftExit = new HeliosTrigger(controllerInterface, _name, "left", "exited", "Fires when the hat leaves the left position."); _triggers.Add(_leftExit); _upEnter = new HeliosTrigger(controllerInterface, _name, "up", "entered", "Fires when hat enters the up position."); _triggers.Add(_upEnter); _upExit = new HeliosTrigger(controllerInterface, _name, "up", "exited", "Fires when the hat leaves the up position."); _triggers.Add(_upExit); _upLeftEnter = new HeliosTrigger(controllerInterface, _name, "up and left", "entered", "Fires when hat enters the upper left position."); _triggers.Add(_upLeftEnter); _upLeftExit = new HeliosTrigger(controllerInterface, _name, "up and left", "exited", "Fires when the hat leaves the upper left position."); _triggers.Add(_upLeftExit); _upRightEnter = new HeliosTrigger(controllerInterface, _name, "up and right", "entered", "Fires when hat enters the upper right position."); _triggers.Add(_upRightEnter); _upRightExit = new HeliosTrigger(controllerInterface, _name, "up and right", "exited", "Fires when the hat leaves the upper right position."); _triggers.Add(_upRightExit); _downEnter = new HeliosTrigger(controllerInterface, _name, "down", "entered", "Fires when hat enters the down position."); _triggers.Add(_downEnter); _downExit = new HeliosTrigger(controllerInterface, _name, "down", "exited", "Fires when the hat leaves the down position."); _triggers.Add(_downExit); _downLeftEnter = new HeliosTrigger(controllerInterface, _name, "down and left", "entered", "Fires when hat enters the downper left position."); _triggers.Add(_downLeftEnter); _downLeftExit = new HeliosTrigger(controllerInterface, _name, "down and left", "exited", "Fires when the hat leaves the downper left position."); _triggers.Add(_downLeftExit); _downRightEnter = new HeliosTrigger(controllerInterface, _name, "down and right", "entered", "Fires when hat enters the downper right position."); _triggers.Add(_downRightEnter); _downRightExit = new HeliosTrigger(controllerInterface, _name, "down and right", "exited", "Fires when the hat leaves the downper right position."); _triggers.Add(_downRightExit); }
public DirectXControllerButton(DirectXControllerInterface controllerInterface, int buttonNumber, JoystickState initialState) { _buttonNumber = buttonNumber; _name = "Button " + (_buttonNumber + 1); _value = new HeliosValue(controllerInterface, new BindingValue(GetValue(initialState)), "", _name, "Current state for " + _name + ".", "True if pressed, false other wise.", BindingValueUnits.Boolean); _press = new HeliosTrigger(controllerInterface, "", _name, "pressed", "Fires when " + _name + " is pressed.", "Always returns true.", BindingValueUnits.Boolean); _release = new HeliosTrigger(controllerInterface, "", _name, "released", "Fires when " + _name + " is released.", "Always returns false.", BindingValueUnits.Boolean); _triggers.Add(_press); _triggers.Add(_release); _lastPollValue = GetValue(initialState); }
public DirectXControllerButton(DirectXControllerInterface controllerInterface, int buttonNumber, JoystickState initialState) { _buttonNumber = buttonNumber; _name = "Button " + (_buttonNumber + 1); _value = new HeliosValue(controllerInterface, new BindingValue(GetValue(initialState)), "", _name, "Current state for " + _name + ".", "True if pressed, false other wise.", BindingValueUnits.Boolean); _press = new HeliosTrigger(controllerInterface, "", _name, "pressed", "Fires when " + _name + " is pressed.", "Always returns true.", BindingValueUnits.Boolean); _release = new HeliosTrigger(controllerInterface, "", _name, "released", "Fires when " + _name + " is released.", "Always returns false.", BindingValueUnits.Boolean); _triggers.Add(_press); _triggers.Add(_release); _lastPollValue = GetValue(initialState); }
public static DirectXControllerFunction CreateDummy(DirectXControllerInterface controllerInterface, string type, int objectNumber) { DirectXControllerFunction function = null; JoystickState state = new JoystickState(); switch (type) { case "X Axis": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.X, objectNumber, state); break; case "Y Axis": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Y, objectNumber, state); break; case "Z Axis": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Z, objectNumber, state); break; case "X Rotation": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Rx, objectNumber, state); break; case "Y Rotation": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Ry, objectNumber, state); break; case "Z Rotation": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Rz, objectNumber, state); break; case "Slider": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Slider, objectNumber, state); break; case "Button": function = new DirectXControllerButton(controllerInterface, objectNumber, state); break; case "POV": function = new DirectXControllerPOVHat(controllerInterface, objectNumber); break; } return(function); }
public static DirectXControllerFunction Create(DirectXControllerInterface controllerInterface, Guid objectType, int objectNumber, JoystickState initialState) { DirectXControllerFunction function = null; if (objectType == ObjectGuid.Button) { function = new DirectXControllerButton(controllerInterface, objectNumber, initialState); } else if (objectType == ObjectGuid.Slider) { function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Slider, objectNumber, initialState); } else if (objectType == ObjectGuid.XAxis) { function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.X, objectNumber, initialState); } else if (objectType == ObjectGuid.YAxis) { function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Y, objectNumber, initialState); } else if (objectType == ObjectGuid.ZAxis) { function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Z, objectNumber, initialState); } else if (objectType == ObjectGuid.RxAxis) { function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Rx, objectNumber, initialState); } else if (objectType == ObjectGuid.RyAxis) { function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Ry, objectNumber, initialState); } else if (objectType == ObjectGuid.RzAxis) { function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Rz, objectNumber, initialState); } else if (objectType == ObjectGuid.PovController) { function = new DirectXControllerPOVHat(controllerInterface, objectNumber, initialState); } return(function); }
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) { if (e.Property == InterfaceProperty) { DirectXControllerInterface oldInterface = e.OldValue as DirectXControllerInterface; if (oldInterface != null) { oldInterface.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(Interface_PropertyChanged); } DirectXControllerInterface newInterface = e.NewValue as DirectXControllerInterface; if (newInterface != null) { newInterface.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(Interface_PropertyChanged); newInterface.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Interface_PropertyChanged); } UpdateControllerDisplay(); } base.OnPropertyChanged(e); }
public static DirectXControllerFunction CreateDummy(DirectXControllerInterface controllerInterface, string type, int objectNumber) { DirectXControllerFunction function = null; JoystickState state = new JoystickState(); switch (type) { case "X Axis": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.X, objectNumber, state); break; case "Y Axis": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Y, objectNumber, state); break; case "Z Axis": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Z, objectNumber, state); break; case "X Rotation": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Rx, objectNumber, state); break; case "Y Rotation": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Ry, objectNumber, state); break; case "Z Rotation": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Rz, objectNumber, state); break; case "Slider": function = new DirectXControllerAxis(controllerInterface, DirectXControllerAxis.AxisType.Slider, objectNumber, state); break; case "Button": function = new DirectXControllerButton(controllerInterface, objectNumber, state); break; case "POV": function = new DirectXControllerPOVHat(controllerInterface, objectNumber); break; } return function; }
void Timer_Tick(object sender, EventArgs e) { DirectXControllerInterface dxInterface = Interface as DirectXControllerInterface; if (dxInterface != null && dxInterface.IsValid) { JoystickState state = dxInterface.GetState(); foreach (KeyValuePair <DirectXControllerButton, ButtonIndicator> pair in _buttons) { pair.Value.IsPushed = pair.Key.GetValue(state); } foreach (KeyValuePair <DirectXControllerAxis, AxisBar> pair in _axis) { pair.Value.Value = pair.Key.GetValue(state); } foreach (KeyValuePair <DirectXControllerPOVHat, PointOfViewIndicator> pair in _povs) { pair.Value.Direction = pair.Key.GetValue(state); } } }
public DirectXControllerPOVHat(DirectXControllerInterface controllerInterface, int povNumber, JoystickState initialState) : this(controllerInterface, povNumber) { _lastPollValue = GetValue(initialState); _value.SetValue(new BindingValue((double)_lastPollValue), true); }
private void UpdateControllerDisplay() { AxisPanel.Children.Clear(); ButtonPanel.Children.Clear(); _buttons.Clear(); DirectXControllerInterface controller = Interface as DirectXControllerInterface; if (controller != null) { foreach (DirectXControllerFunction function in controller.Functions) { DirectXControllerButton button = function as DirectXControllerButton; if (button != null) { ButtonIndicator indicator = new ButtonIndicator(); indicator.Width = 30; indicator.Height = 30; indicator.Label = (button.ObjectNumber + 1).ToString(); indicator.Margin = new Thickness(2); _buttons.Add(button, indicator); ButtonPanel.Children.Add(indicator); } DirectXControllerAxis axis = function as DirectXControllerAxis; if (axis != null) { AxisBar bar = new AxisBar(); bar.BarWidth = 30; bar.Height = 110; bar.Label = axis.Name; bar.BorderThickness = new Thickness(1d); bar.BorderBrush = Brushes.DarkGray; bar.Margin = new Thickness(10, 2, 0, 2); _axis.Add(axis, bar); AxisPanel.Children.Add(bar); } DirectXControllerPOVHat hat = function as DirectXControllerPOVHat; if (hat != null) { PointOfViewIndicator pov = new PointOfViewIndicator(); pov.Width = 60; pov.Height = 60; pov.Direction = POVDirection.Center; TextBlock label = new TextBlock(); label.Width = 60; label.Text = hat.Name; StackPanel panel = new StackPanel(); panel.Margin = new Thickness(10, 2, 0, 2); panel.Children.Add(pov); panel.Children.Add(label); _povs.Add(hat, pov); POVPanel.Children.Add(panel); } } if (_axis.Count > 0) { AxisGroup.Visibility = System.Windows.Visibility.Visible; } else { AxisGroup.Visibility = System.Windows.Visibility.Collapsed; } if (_buttons.Count > 0) { ButtonGroup.Visibility = System.Windows.Visibility.Visible; } else { ButtonGroup.Visibility = System.Windows.Visibility.Collapsed; } if (_povs.Count > 0) { POVGroup.Visibility = System.Windows.Visibility.Visible; } else { POVGroup.Visibility = System.Windows.Visibility.Collapsed; } } }
public DirectXControllerPOVHat(DirectXControllerInterface controllerInterface, int povNumber, JoystickState initialState) : this(controllerInterface, povNumber) { _lastPollValue = GetValue(initialState); _value.SetValue(new BindingValue((double)_lastPollValue), true); }