public static bool SetTrigger(uint userIndex, XboxTrigger trigger, byte value) { if (!VirtualXboxController.IsOwned(userIndex)) { return(false); } if (!NativeMethods.SetTrigger(userIndex, (uint)trigger, value)) { return(false); } switch (trigger) { case XboxTrigger.Left: states[(int)userIndex - 1].LeftTriggerValue = value; break; case XboxTrigger.Right: states[(int)userIndex - 1].RightTriggerValue = value; break; default: throw new NotImplementedException( "Not implemented Xbox trigger: " + trigger); } return(true); }
public static bool SetButton(uint userIndex, XboxButton button, bool value) { if (!VirtualXboxController.IsOwned(userIndex)) { return(false); } bool isButtonSet = NativeMethods.SetButton(userIndex, (uint)button, value); if (isButtonSet) { var buttonStates = states[(int)userIndex - 1].ButtonsDown; if (value == true) { if (!buttonStates.Contains(button)) { buttonStates.Add(button); } } else { if (buttonStates.Contains(button)) { buttonStates.Remove(button); } } } return(isButtonSet); }
public static string Uninstall() { if (!VirtualXboxBus.IsInstalled) { return("Error: ScpVBus is already uninstalled"); } VirtualXboxController.UnPlug(1, true); VirtualXboxController.UnPlug(2, true); VirtualXboxController.UnPlug(3, true); VirtualXboxController.UnPlug(4, true); string output = null; try { string devConFullPath = LoadDriverResourcesAndGetDevconPath(); var startInfo = new ProcessStartInfo(devConFullPath + " ", @"remove Root\ScpVBus"); startInfo.WorkingDirectory = Path.GetDirectoryName(devConFullPath); startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.Verb = "runas"; using (var proc = Process.Start(startInfo)) { output = proc.StandardOutput.ReadToEnd(); proc.WaitForExit(); return("Output from ScpVBus uninstall: " + output); } } catch (Exception ex) { return("ScpVbus uninstall failed:\r\n" + ex.ToString()); } }
public static bool SetAxis(uint userIndex, XboxAxis axis, XboxAxisPosition position) { if (!VirtualXboxController.IsOwned(userIndex)) { return(false); } return(VirtualXboxController.SetAxis(userIndex, axis, (short)position)); }
public static bool UnPlug(uint userIndex, bool force = false) { if (NativeMethods.Unplug(userIndex, force)) { VirtualXboxController.ResetStates(userIndex); return(true); } return(false); }
public static bool PlugIn(uint userIndex) { if (NativeMethods.PlugIn(userIndex)) { VirtualXboxController.ResetStates(userIndex); return(true); } return(false); }
public static bool SetDPad(uint userIndex, XboxDpadDirection directions) { if (!VirtualXboxController.IsOwned(userIndex)) { return(false); } if (NativeMethods.SetDpad(userIndex, (int)directions)) { states[(int)userIndex - 1].DpadDirections = directions; return(true); } return(false); }
public static bool SetAxis(uint userIndex, XboxAxis axis, short value) { if (!VirtualXboxController.IsOwned(userIndex)) { return(false); } if (!NativeMethods.SetAxis(userIndex, (uint)axis, value)) { return(false); } switch (axis) { case XboxAxis.X: states[(int)userIndex - 1].AxisXValue = value; break; case XboxAxis.Y: states[(int)userIndex - 1].AxisYValue = value; break; case XboxAxis.Rx: states[(int)userIndex - 1].AxisRxValue = value; break; case XboxAxis.Ry: states[(int)userIndex - 1].AxisRyValue = value; break; default: throw new NotImplementedException( "Not implemented xbox axis: " + axis); } return(true); }