protected EmulationSlotBase(uint slotNumber, IVirtualGamepad gamepad, Keyboard keyboard, Mouse mouse, IPreset preset) : this() { if (gamepad == null) { throw new ArgumentNullException("gamepad"); } if (preset == null) { throw new ArgumentNullException("preset"); } if (keyboard == null) { throw new ArgumentNullException("keyboard"); } if (mouse == null) { throw new ArgumentNullException("mouse"); } this.SlotNumber = slotNumber; this.Gamepad = gamepad; this.Keyboard = keyboard; this.Mouse = mouse; this.Preset = preset; }
private string SetAxis(IVirtualGamepad gamepad, Mapping mapping, bool isKeyDown, bool hasOppositeDown) { uint axis = (uint)mapping.Function; short axisValue = (short)mapping.TargetValue; short oldValue = gamepad.GetAxisState(axis); short newValue = (short)XboxAxisPosition.Center; if (isKeyDown && !hasOppositeDown) { newValue = axisValue; } if (hasOppositeDown && !isKeyDown) { if ((short)mapping.TargetValue == (short)XboxAxisPosition.Min) { newValue = (short)XboxAxisPosition.Max; } else { newValue = (short)XboxAxisPosition.Min; } } if (oldValue == newValue) { return(null); } gamepad.SetAxisState(axis, newValue); return(((XinputAxis)axis) + " Axis " + ((XboxAxisPosition)newValue)); }
private void SetAxis(IVirtualGamepad gamepad, Mapping mapping, bool isKeyDown, bool hasOppositeDown) { uint axis = (uint)mapping.Function; short axisValue = (short)mapping.TargetValue; short oldValue = gamepad.GetAxisState(axis); short newValue = isKeyDown ? axisValue : (short)XboxAxisPosition.Center; if (hasOppositeDown && !isKeyDown) { if ((short)mapping.TargetValue == (short)XboxAxisPosition.Min) { newValue = (short)XboxAxisPosition.Max; } else { newValue = (short)XboxAxisPosition.Min; } } if (oldValue == newValue) { return; } gamepad.SetAxisState(axis, newValue); }
/// <summary> /// Connects the XboxGamepad to the console. /// </summary> /// <param name="systemIpAddress">The system IP address of the console.</param> /// <returns>The id of the XboxGamepad.</returns> protected override ulong ConnectXboxGamepadImpl(string systemIpAddress) { IVirtualGamepad gamepad = this.XboxXdk.CreateXboxGamepad(systemIpAddress); this.gamepads.Add(gamepad); return(gamepad.Connect()); }
private void SetDpad(IVirtualGamepad gamepad, Mapping mapping, bool isKeyDown) { int direction = (int)mapping.Function; int oldValue = gamepad.GetDpadState(); int newValue = isKeyDown ? oldValue | direction : oldValue & ~direction; if (oldValue == newValue) { return; } gamepad.SetDpadState(newValue); }
private void SetTrigger(IVirtualGamepad gamepad, Mapping mapping, bool isKeyDown) { uint trigger = (uint)mapping.Function; byte currentValue = gamepad.GetTriggerState(trigger); byte newValue = isKeyDown ? byte.MaxValue : byte.MinValue; if (currentValue == newValue) { return; } gamepad.SetTriggerState(trigger, newValue); }
private void SetButton(IVirtualGamepad gamepad, Mapping mapping, bool isKeyDown) { uint button = (uint)mapping.Function; bool currentValue = gamepad.GetButtonState(button); bool newValue = isKeyDown; if (currentValue == newValue) { return; } gamepad.SetButtonState(button, newValue); }
private string SetDpad(IVirtualGamepad gamepad, Mapping mapping, bool isKeyDown) { int direction = (int)mapping.Function; int oldValue = gamepad.GetDpadState(); int newValue = isKeyDown ? oldValue | direction : oldValue & ~direction; if (oldValue == newValue) { return(null); } gamepad.SetDpadState(newValue); return(((XinputButton)newValue).ToString()); }
private string SetTrigger(IVirtualGamepad gamepad, Mapping mapping, bool isKeyDown) { uint trigger = (uint)mapping.Function; byte currentValue = gamepad.GetTriggerState(trigger); byte newValue = isKeyDown ? byte.MaxValue : byte.MinValue; if (currentValue == newValue) { return(null); } gamepad.SetTriggerState(trigger, newValue); return(((XinputTrigger)newValue).ToString()); }
private string SetButton(IVirtualGamepad gamepad, Mapping mapping, bool isKeyDown) { uint button = (uint)mapping.Function; bool currentValue = gamepad.GetButtonState(button); bool newValue = isKeyDown; if (currentValue == newValue) { return(null); } gamepad.SetButtonState(button, newValue); return(((XinputButton)button).ToString()); }
public async Task Start(IPAddress iPAddress) { _controller = MainWindow.Instance.Settings.TargetType == TargetType.Xbox360 ? (IVirtualGamepad)_viGEmClient.CreateXbox360Controller() : _viGEmClient.CreateDualShock4Controller(); _controller.AutoSubmitReport = false; _controller.Connect(); _dummy = new Dummy(iPAddress) { Running = true }; _connectToken = new CancellationTokenSource(); Dummy.ConnectedHandler handler = (d) => _connectToken.Cancel(); _dummy.Connected += handler; _dummy.StateChanged += OnStateChanged; _ = Task.Run(() => _dummy.HandleLoop()); await Task.Delay(-1, _connectToken.Token).ContinueWith((t) => { }); _dummy.Connected -= handler; }