readonly long BUTTON_FILTER = 0; // Ignore new button presses less than this (ms) public AxisProcessor(int axisSensitivity, OutputAxis outputAxis) { Debug.WriteLine("Multiplier is {0}", axisSensitivity); _sensitivity = axisSensitivity; _vJoyId = outputAxis.VJoyDevice; _vJoyAxisNumber = outputAxis.VJoyItem; _joystick = new vJoy(); if (!_joystick.vJoyEnabled()) { Debug.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes.\n"); } else { Debug.WriteLine("Vendor: {0}\nProduct :{1}\nVersion Number:{2}\n", _joystick.GetvJoyManufacturerString(), _joystick.GetvJoyProductString(), _joystick.GetvJoySerialNumberString()); } // Acquire the target (Not currently used really...) VjdStat status = _joystick.GetVJDStatus(_vJoyId); Debug.WriteLine("vJoy Status: " + status.ToString()); if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!_joystick.AcquireVJD(_vJoyId)))) { Debug.WriteLine("Failed to acquire vJoy device number {0}.", _vJoyId); } _joystick.GetVJDAxisMax(_vJoyId, (HID_USAGES)_vJoyAxisNumber, ref _maxAxisValue); Debug.WriteLine("Max value of VJID {0} axis {1} is {2}", _vJoyId, (HID_USAGES)_vJoyAxisNumber, _maxAxisValue); Centre(); }
/// <summary> /// Enable vJoy /// </summary> /// <returns></returns> public int EnablevJoy() { // Get the driver attributes (Vendor ID, Product ID, Version Number) if (!Joystick.vJoyEnabled()) { Log("vJoy driver not enabled: Failed Getting vJoy attributes.", LogLevels.ERROR); return(-2); } else { LogFormat(LogLevels.DEBUG, "Vendor: {0}\tProduct :{1}\tVersion Number:{2}", Joystick.GetvJoyManufacturerString(), Joystick.GetvJoyProductString(), Joystick.GetvJoySerialNumberString()); } // Test if DLL matches the driver this.vJoyVersionMatch = Joystick.DriverMatch(ref this.vJoyVersionDll, ref this.vJoyVersionDriver); if (this.vJoyVersionMatch) { LogFormat(LogLevels.DEBUG, "Version of Driver Matches DLL Version ({0:X})", this.vJoyVersionDll); return(1); } else { LogFormat(LogLevels.ERROR, "Version of Driver ({0:X}) does NOT match DLL Version ({1:X})", this.vJoyVersionDriver, this.vJoyVersionDll); return(-1); } }
public Gamepad(GamepadConfiguration config, uint gamepadId) { _config = config; _vJoy = new vJoy(); _gamepadId = gamepadId; if (!_vJoy.vJoyEnabled()) { Log(@"vJoy driver not enabled: Failed Getting vJoy attributes."); return; } uint dllVer = 0, drvVer = 0; var match = _vJoy.DriverMatch(ref dllVer, ref drvVer); if (!match) { Log($@"Version of Driver ({drvVer:X}) does NOT match DLL Version ({dllVer:X})\n"); return; } var status = _vJoy.GetVJDStatus(_gamepadId); if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && !_vJoy.AcquireVJD(_gamepadId))) { Log($@"Failed to acquire vJoy device number {_gamepadId}.\n"); return; } ResetGamepad(_gamepadId); }
private void InitJoystick() { lock (lockObj) { // Verify the vJoy driver is enabled. if (!VirtualJoystick.vJoyEnabled()) { throw new VJoyNotEnabledException("vJoy is not enabled! Please install and enable vJoy!"); } // Get the state of the requested device. VjdStat Status = VirtualJoystick.GetVJDStatus(JoystickID); switch (Status) { case VjdStat.VJD_STAT_OWN: case VjdStat.VJD_STAT_FREE: break; case VjdStat.VJD_STAT_BUSY: case VjdStat.VJD_STAT_MISS: default: throw new VJoyAccessException("Cannot access vJoy! Code: " + Status.ToString()); } ; // Acquire the target joystick. if (!VirtualJoystick.AcquireVJD(JoystickID)) { throw new VJoyAcquisitionException("Could not acquire vJoy with ID: " + JoystickID.ToString()); } // Open the Stream Deck device. try { Deck = StreamDeck.OpenDevice(); } catch (Exception ex) { //Catch the internal StreamDeck error and handle it our way. Deck = null; #if DEBUG Console.WriteLine(ex.ToString()); #endif } if (Deck == null || !Deck.IsConnected) { throw new StreamDeckAccessException("Stream Deck could not be opened!"); } // Set the brightness of the keys. Deck.SetBrightness(100); // Register the key pressed event handler. Deck.KeyStateChanged += StreamDeckKeyPressed; } ReloadButtonImages(); }
public VJoyDevice(uint id) { device = new vJoy(); this.id = id; if (!device.vJoyEnabled()) { throw new Exception("vJoy driver not enabled."); } VjdStat status = device.GetVJDStatus(id); if (status == VjdStat.VJD_STAT_BUSY) { throw new Exception("vJoy device is already in use."); } else if (status == VjdStat.VJD_STAT_MISS) { throw new Exception("vJoy device is not installed or disabled."); } if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!device.AcquireVJD(id)))) { throw new Exception("Failed to acquire vJoy device " + id + "."); } }
public void init_vjoy() { try { joystick = new vJoy(); if (!joystick.vJoyEnabled()) { MessageBox.Show("vJoy driver not enabled: Failed Getting vJoy attributes."); return; } VjdStat status = joystick.GetVJDStatus(id); // Test if DLL matches the driver UInt32 DllVer = 0, DrvVer = 0; bool match = joystick.DriverMatch(ref DllVer, ref DrvVer); //if (match) //MessageBox.Show("Version of Driver Matches DLL Version ("+ DllVer.ToString()+")"); //else //MessageBox.Show("Version of Driver (" + DrvVer.ToString() + ") does NOT match DLL Version (" + DllVer.ToString() + ")"); joystick.AcquireVJD(id); } catch { MessageBox.Show("vjoy failed to init"); } }
public VirtualController(uint ID) { this.ID = ID; this.joystick = new vJoy(); if (!ControllerCache.VCCheck) { if (!joystick.vJoyEnabled()) { logger.Fatal("vJoy driver not enabled: Failed Getting vJoy attributes."); return; } else { logger.Info("Vendor: {0}; Product :{1}; Version Number:{2}", joystick.GetvJoyManufacturerString(), joystick.GetvJoyProductString(), joystick.GetvJoySerialNumberString() ); } // check driver version against local DLL version uint DllVer = 0, DrvVer = 0; if (!this.joystick.DriverMatch(ref DllVer, ref DrvVer)) { logger.Error("Version of vJoy Driver ({0:X}) NOT MATCH NOT MATCH vJoy DLL Version ({1:X})", DrvVer, DllVer); } else { logger.Info("Version of vJoy Driver ({0:X}), vJoy DLL Version ({1:X})", DrvVer, DllVer); } ControllerCache.VCCheck = true; } }
public void Initialize() { if (Initialized == true) { return; } VJoyInstance = new vJoy(); if (VJoyInstance.vJoyEnabled() == false) { Console.WriteLine("vJoy driver not enabled!"); return; } //Kimimaru: The data object passed in here will be returned in the callback //This can be used to update the object's data when a vJoy device is connected or disconnected from the computer //This does not get fired when the vJoy device is acquired or relinquished VJoyInstance.RegisterRemovalCB(OnDeviceRemoved, null); string vendor = VJoyInstance.GetvJoyManufacturerString(); string product = VJoyInstance.GetvJoyProductString(); string serialNum = VJoyInstance.GetvJoySerialNumberString(); Console.WriteLine($"vJoy driver found - Vendor: {vendor} | Product: {product} | Version: {serialNum}"); uint dllver = 0; uint drvver = 0; bool match = VJoyInstance.DriverMatch(ref dllver, ref drvver); Console.WriteLine($"Using vJoy DLL version {dllver} and vJoy driver version {drvver} | Version Match: {match}"); //int acquiredCount = InitControllers(BotProgram.BotData.JoystickCount); //Console.WriteLine($"Acquired {acquiredCount} controllers!"); }
private static vJoy InitVJoy() { var vJoy = new vJoy(); if (!vJoy.vJoyEnabled()) { Console.WriteLine("vJoy driver not enabled"); return(null); } // Check if dll matches the driver version uint verDll = 0, verDrv = 0; bool match = vJoy.DriverMatch(ref verDll, ref verDrv); if (match) { Console.WriteLine("vJoy driver and DLL are same version ({0:X})", verDll); } else { Console.WriteLine("vJoy driver ({0:X}) and DLL ({1:x}) version mismatch (could work anyway)", verDrv, verDll); } return(vJoy); }
void checkvJoy() { uint dllv = 0, drvv = 0; if (joy.vJoyEnabled()) { setStat(stat.VJDriverOK); if (joy.DriverMatch(ref dllv, ref drvv)) //todo ver to hex to pretty string { setStat(stat.VJLibVerMatch); tooltiper.SetToolTip(imgStatvJoyLib, "Driver version matches library version (" + drvv.ToString("x") + ')'); } else { setStat(stat.VJLibVerProblem); tooltiper.SetToolTip(imgStatvJoyLib, "Driver version: " + drvv.ToString("x") + "\nLibrary version: " + dllv.ToString("x")); } } else { tooltiper.SetToolTip(imgStatvJoyOk, "Check vJoy driver and restart this program"); tooltiper.SetToolTip(imgStatvJoyLib, "I can't use library without driver"); } refreshStatusIcons(stat.VJOK); }
public void Initialize() { if (Initialized == true) { return; } VJoyInstance = new vJoy(); if (VJoyInstance.vJoyEnabled() == false) { TRBotLogger.Logger.Error("vJoy driver not enabled!"); return; } //The data object passed in here will be returned in the callback //This can be used to update the object's data when a vJoy device is connected or disconnected from the computer //This does not get fired when the vJoy device is acquired or relinquished VJoyInstance.RegisterRemovalCB(OnDeviceRemoved, null); string vendor = VJoyInstance.GetvJoyManufacturerString(); string product = VJoyInstance.GetvJoyProductString(); string serialNum = VJoyInstance.GetvJoySerialNumberString(); TRBotLogger.Logger.Information($"vJoy driver found - Vendor: {vendor} | Product: {product} | Version: {serialNum}"); uint dllver = 0; uint drvver = 0; bool match = VJoyInstance.DriverMatch(ref dllver, ref drvver); TRBotLogger.Logger.Information($"Using vJoy DLL version {dllver} and vJoy driver version {drvver} | Version Match: {match}"); }
public EDStatusFeeder() { if (!vJoy.vJoyEnabled()) { throw new Exception("vJoy not enabled!"); } ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem itemConfig = new ToolStripMenuItem("Configuration"); itemConfig.Click += Config; itemConfig.Font = new System.Drawing.Font(itemConfig.Font, System.Drawing.FontStyle.Bold); menu.Items.Add(itemConfig); menu.Items.Add(new ToolStripSeparator()); ToolStripMenuItem itemExit = new ToolStripMenuItem("Exit"); itemExit.Click += Exit; menu.Items.Add(itemExit); // Initialize Tray Icon trayIcon.ContextMenuStrip = menu; trayIcon.DoubleClick += Config; if (Configuration.Data.DeviceId == 0) { ShowConfigurationMenu(); } else { TrayNotify("Status Feeder is now active"); } StatusChanged(); EDStatusMonitor.MonitorInstance.Changed += StatusChanged; }
private void ConnectClient() { try { VJoy = new vJoy(); if (!VJoy.vJoyEnabled()) { Connection.LogSDMessage("vJoy driver not enabled: Failed Getting vJoy attributes."); Logger.Instance.LogMessage(TracingLevel.ERROR, "vJoy driver not enabled: Failed Getting vJoy attributes."); } else { Connection.LogSDMessage($"Vendor: {VJoy.GetvJoyManufacturerString()}\nProduct :{VJoy.GetvJoyProductString()}\nVersion Number:{VJoy.GetvJoySerialNumberString()}\n"); Logger.Instance.LogMessage(TracingLevel.INFO, $"Vendor: {VJoy.GetvJoyManufacturerString()}\nProduct :{VJoy.GetvJoyProductString()}\nVersion Number:{VJoy.GetvJoySerialNumberString()}\n"); } if (!VJoy.AcquireVJD(JoystickId)) { Connection.ShowAlert().Start(); } else { VJoy.ResetAll(); } } catch (ArgumentException ex) { Connection.LogSDMessage($"{ex.Message}"); Logger.Instance.LogMessage(TracingLevel.ERROR, $"{ex.Message}"); } }
const int PULSE_LENGTH = 60; //ms public ButtonProcessor(int multiplier, int holdThresholdStart, int holdThresholdStop, OutputButton outputButton) { _multiplier = multiplier; _holdThresholdStart = holdThresholdStart; _holdThresholdStop = holdThresholdStop; _vJoyId = outputButton.VJoyDevice; _vJoyButtonNumber = outputButton.VJoyItem; _joystick = new vJoy(); if (!_joystick.vJoyEnabled()) { Debug.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes.\n"); } else { Debug.WriteLine("Vendor: {0}\nProduct :{1}\nVersion Number:{2}\n", _joystick.GetvJoyManufacturerString(), _joystick.GetvJoyProductString(), _joystick.GetvJoySerialNumberString()); } // Acquire the target VjdStat status = _joystick.GetVJDStatus(_vJoyId); if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!_joystick.AcquireVJD(_vJoyId)))) { Debug.WriteLine("Failed to acquire vJoy device number {0}.", _vJoyId); return; } else { Debug.WriteLine("Acquired: vJoy device number {0}.", _vJoyId); } _joystick.ResetVJD(_vJoyId); }
public void ValidateHost() { // Get the driver attributes (Vendor ID, Product ID, Version Number) if (!vjoy.vJoyEnabled()) { Console.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes.\n"); return; } else { Console.WriteLine("Vendor: {0}\nProduct :{1}\nVersion Number:{2}\n", vjoy.GetvJoyManufacturerString(), vjoy.GetvJoyProductString(), vjoy.GetvJoySerialNumberString()); } // Test if DLL matches the driver UInt32 DllVer = 0, DrvVer = 0; bool match = vjoy.DriverMatch(ref DllVer, ref DrvVer); if (match) { Console.WriteLine("Version of Driver Matches DLL Version ({0:X})\n", DllVer); } else { Console.WriteLine("Version of Driver ({0:X}) does NOT match DLL Version ({1:X})\n", DrvVer, DllVer); } }
void OnEnable() { vjoy = new vJoy(); if (!vjoy.vJoyEnabled()) { SetStatus(VJoyStatus.NotInstalled); enabled = false; return; } uint DllVer = 0, DrvVer = 0; bool match = vjoy.DriverMatch(ref DllVer, ref DrvVer); if (match) { Debug.LogFormat("vJoy Driver Version Matches vJoy DLL Version ({0:X})", DllVer); } else { Debug.LogErrorFormat("vJoy Driver Version ({0:X}) does NOT match vJoy DLL Version ({1:X})", DrvVer, DllVer); SetStatus(VJoyStatus.VersionMismatch); enabled = false; return; } VjdStat deviceStatus = vjoy.GetVJDStatus(deviceId); VjdStat secondaryDeviceStatus = vjoy.GetVJDStatus(secondaryDeviceId); if (!IsDeviceStatusOk(deviceId, deviceStatus) || !IsDeviceStatusOk(secondaryDeviceId, secondaryDeviceStatus)) { enabled = false; return; } if (!IsDeviceValid(deviceId)) { Debug.LogError("vJoy device is not configured correctly"); SetStatus(VJoyStatus.DeviceMisconfigured); enabled = false; return; } if (!IsSecondaryDeviceValid(deviceId)) { Debug.LogError("Secondary vJoy device is not configured correctly"); SetStatus(VJoyStatus.DeviceMisconfigured); enabled = false; return; } if (!AcquireDevice(deviceId, deviceStatus) || !AcquireDevice(secondaryDeviceId, secondaryDeviceStatus)) { enabled = false; return; } SetStatus(VJoyStatus.Ready); }
private void Initialize_vJoy() { // Create one joystick object and a position structure. joystick = new vJoy(); iReport = new vJoy.JoystickState(); // Get the driver attributes (Vendor ID, Product ID, Version Number) if (!joystick.vJoyEnabled()) { MessageBox.Show("vJoy driver not enabled: Failed Getting vJoy attributes.\n"); Program._shouldExit = true; System.Environment.Exit(0); } // Get the state of the requested device VjdStat status = joystick.GetVJDStatus(id); switch (status) { case VjdStat.VJD_STAT_OWN: break; case VjdStat.VJD_STAT_FREE: break; case VjdStat.VJD_STAT_BUSY: MessageBox.Show("vJoy Device is already owned by another feeder\nInput feeding will not occur."); //System.Environment.Exit(0); return; case VjdStat.VJD_STAT_MISS: MessageBox.Show("vJoy Device is not installed or disabled\nInput feeding will not occur."); //System.Environment.Exit(0); return; default: MessageBox.Show("vJoy Device general error\nInput feeding will not occur."); //System.Environment.Exit(0); return; } ; // Get the number of buttons and POV Hat switchessupported by this vJoy device int nButtons = joystick.GetVJDButtonNumber(id); int ContPovNumber = joystick.GetVJDContPovNumber(id); int DiscPovNumber = joystick.GetVJDDiscPovNumber(id); // Acquire the target if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!joystick.AcquireVJD(id)))) { MessageBox.Show("Failed to acquire vJoy device number"); Program._shouldExit = true; System.Environment.Exit(0); } joystick.ResetVJD(id); }
public MainWindow() { InitializeComponent(); this.Leap_Controller = new Controller(); this.Leap_Listener = new LeapEventListener(this); Leap_Controller.AddListener(Leap_Listener); Leap_Controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES); vJoy_Joystick = new vJoy(); if (!vJoy_Joystick.vJoyEnabled()) { return; } UInt32 DllVer = 0, DrvVer = 0; vJoy_Joystick.DriverMatch(ref DllVer, ref DrvVer); vJoy_Joystick.AcquireVJD(vJoy_id); vJoy_Joystick.ResetVJD(vJoy_id); Trig_En = new SolidColorBrush(Colors.LightGreen); Trig_Dis = Text_Trig_Max_Up.Background; try { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("LeapJoySets.bin", FileMode.Open, FileAccess.Read, FileShare.Read); Data_Set = (DataSet)formatter.Deserialize(stream); stream.Close(); } catch { Data_Set = new DataSet(); } Text_Max_Up.Text = Data_Set.Axis_Max_Up.ToString(); Text_Max_Pitch.Text = Data_Set.Axis_Max_Pitch.ToString(); Text_Max_Roll.Text = Data_Set.Axis_Max_Roll.ToString(); Text_Max_Yaw.Text = Data_Set.Axis_Max_Yaw.ToString(); Text_Min_Up.Text = Data_Set.Axis_Min_Up.ToString(); Text_Min_Pitch.Text = Data_Set.Axis_Min_Pitch.ToString(); Text_Min_Roll.Text = Data_Set.Axis_Min_Roll.ToString(); Text_Min_Yaw.Text = Data_Set.Axis_Min_Yaw.ToString(); Text_Trig_Max_Up.Text = Data_Set.Axis_Trig_Max_Up.ToString(); Text_Trig_Max_Pitch.Text = Data_Set.Axis_Trig_Max_Pitch.ToString(); Text_Trig_Max_Roll.Text = Data_Set.Axis_Trig_Max_Roll.ToString(); Text_Trig_Max_Yaw.Text = Data_Set.Axis_Trig_Max_Yaw.ToString(); Text_Trig_Min_Up.Text = Data_Set.Axis_Trig_Min_Up.ToString(); Text_Trig_Min_Pitch.Text = Data_Set.Axis_Trig_Min_Pitch.ToString(); Text_Trig_Min_Roll.Text = Data_Set.Axis_Trig_Min_Roll.ToString(); Text_Trig_Min_Yaw.Text = Data_Set.Axis_Trig_Min_Yaw.ToString(); rdy = true; }
public VJoyFeeder() { _joystick = new vJoy(); _joystickState = new vJoy.JoystickState(); _id = 1; _joystick.ResetVJD(_id); if (!_joystick.vJoyEnabled()) { Console.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes.\n"); return; } Console.WriteLine("Vendor: {0}\nProduct :{1}\nVersion Number:{2}\n", _joystick.GetvJoyManufacturerString(), _joystick.GetvJoyProductString(), _joystick.GetvJoySerialNumberString()); // Get the state of the requested device VjdStat status = _joystick.GetVJDStatus(_id); switch (status) { case VjdStat.VJD_STAT_OWN: Console.WriteLine("vJoy Device {0} is already owned by this feeder\n", _id); break; case VjdStat.VJD_STAT_FREE: Console.WriteLine("vJoy Device {0} is free\n", _id); break; case VjdStat.VJD_STAT_BUSY: Console.WriteLine("vJoy Device {0} is already owned by another feeder\nCannot continue\n", _id); return; case VjdStat.VJD_STAT_MISS: Console.WriteLine("vJoy Device {0} is not installed or disabled\nCannot continue\n", _id); return; default: Console.WriteLine("vJoy Device {0} general error\nCannot continue\n", _id); return; } ; // Test if DLL matches the driver UInt32 dllVer = 0, drvVer = 0; bool match = _joystick.DriverMatch(ref dllVer, ref drvVer); if (match) { Console.WriteLine("Version of Driver Matches DLL Version ({0:X})\n", dllVer); } else { Console.WriteLine("Version of Driver ({0:X}) does NOT match DLL Version ({1:X})\n", drvVer, dllVer); } _joystick.AcquireVJD(_id); }
/// <summary> /// Checking VJoy - copied from documentation /// </summary> /// <returns></returns> private bool CheckVJoy() { if (!_joystick.vJoyEnabled()) { Console.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes.\n"); return(false); } // Get the state of the requested device VjdStat status = _joystick.GetVJDStatus(_deviceId); switch (status) { case VjdStat.VJD_STAT_OWN: Console.WriteLine("vJoy Device {0} is already owned by this feeder\n", _deviceId); break; case VjdStat.VJD_STAT_FREE: Console.WriteLine("vJoy Device {0} is free\n", _deviceId); break; case VjdStat.VJD_STAT_BUSY: Console.WriteLine("vJoy Device {0} is already owned by another feeder\nCannot continue\n", _deviceId); return(false); case VjdStat.VJD_STAT_MISS: Console.WriteLine("vJoy Device {0} is not installed or disabled\nCannot continue\n", _deviceId); return(false); default: Console.WriteLine("vJoy Device {0} general error\nCannot continue\n", _deviceId); return(false); } // Test if DLL matches the driver UInt32 dllVer = 0, drvVer = 0; bool match = _joystick.DriverMatch(ref dllVer, ref drvVer); if (match) { Console.WriteLine("Version of Driver Matches DLL Version ({0:X})\n", dllVer); } else { Console.WriteLine("Version of Driver ({0:X}) does NOT match DLL Version ({1:X})\n", drvVer, dllVer); } // Acquire the target if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!_joystick.AcquireVJD(_deviceId)))) { Console.WriteLine("Failed to acquire vJoy device number {0}.\n", _deviceId); return(false); } Console.WriteLine("Acquired: vJoy device number {0}.\n", _deviceId); return(true); }
string Joystick(dynamic input) { id = (uint)input.pid; joystick = new vJoy(); iReport = new vJoy.JoystickState(); if (!joystick.vJoyEnabled()) { return("vJoy driver not enabled: Failed Getting vJoy attributes.\n"); } if (started == 0) { status = joystick.GetVJDStatus(id); switch (status) { case VjdStat.VJD_STAT_OWN: case VjdStat.VJD_STAT_FREE: break; case VjdStat.VJD_STAT_MISS: case VjdStat.VJD_STAT_BUSY: default: return("vJoy error\n" + status); } ; if (!joystick.AcquireVJD(id)) { return("Cannot acquire!"); } joystick.ResetVJD(id); } started = 1; bool btnStatus = false; uint btnId = 0; string teste = ""; foreach (dynamic btn in input.buttons) { foreach (dynamic btnP in btn.Value) { if (btnP.Key == "bid") { btnId = (uint)btnP.Value; } if (btnP.Key == "status") { btnStatus = (bool)btnP.Value; } } joystick.SetBtn(btnStatus, id, btnId); teste += " " + btnId + ":(" + btnStatus + ")"; } joystick.SetAxis(((int)input.axis.X), id, HID_USAGES.HID_USAGE_X); joystick.SetAxis(((int)input.axis.Y), id, HID_USAGES.HID_USAGE_Y); return("vJoy Enabled! " + id + teste); }
static void Main(string[] args) { uint index = 1; var joystick = new vJoy(); if (!joystick.vJoyEnabled()) { throw new Exception("vJoy driver not enabled: Failed Getting vJoy attributes"); } var status = joystick.GetVJDStatus(index); string error = null; switch (status) { case VjdStat.VJD_STAT_BUSY: error = "vJoy Device {0} is already owned by another feeder"; break; case VjdStat.VJD_STAT_MISS: error = "vJoy Device {0} is not installed or disabled"; break; case VjdStat.VJD_STAT_UNKN: error = ("vJoy Device {0} general error"); break; } if (error == null && !joystick.AcquireVJD(index)) { error = "Failed to acquire vJoy device number {0}"; } if (error != null) { throw new Exception(string.Format(error, index)); } joystick.ResetVJD(index); if (!FfbStart(index)) { throw new Exception(string.Format("Failed to start Forcefeedback on device {0}", index)); } FfbRegisterGenCB(OnEffect, IntPtr.Zero); Console.ReadLine(); FfbStop(index); joystick.RelinquishVJD(index); }
public override void Acquire(string id) { // Get the driver attributes (Vendor ID, Product ID, Version Number) if (!joystick.vJoyEnabled()) { throw new VJoyException("vJoy driver not enabled: Failed Getting vJoy attributes."); } UInt32 DllVer = 0, DrvVer = 0; bool match = joystick.DriverMatch(ref DllVer, ref DrvVer); if (!match) { throw new VJoyException(String.Format("Version of Driver ({0:X}) does NOT match DLL Version ({1:X})", DrvVer, DllVer)); } if (!int.TryParse(id, out this.id)) { throw new VJoyException(String.Format("Invalid joystcik id {0}", id)); } // Get the state of the requested device VjdStat status = joystick.GetVJDStatus((uint)this.id); switch (status) { case VjdStat.VJD_STAT_OWN: //MessageBox.Show(String.Format("vJoy Device {0} is already owned by this feeder\n", id)); break; case VjdStat.VJD_STAT_FREE: //MessageBox.Show(String.Format("vJoy Device {0} is free\n", id)); break; case VjdStat.VJD_STAT_BUSY: throw new VJoyException(String.Format("vJoy Device {0} is already owned by another feeder\nCannot continue", id)); case VjdStat.VJD_STAT_MISS: throw new VJoyException(String.Format("vJoy Device {0} is not installed or disabled\nCannot continue", id)); default: throw new VJoyException(String.Format("vJoy Device {0} general error\nCannot continue", id)); } ; // Acquire the target if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!joystick.AcquireVJD((uint)this.id)))) { throw new VJoyException(String.Format("Failed to acquire vJoy device number {0}.", id)); } _reset(); }
public MainWindow() { InitializeComponent(); input = new RawInput(this.Handle, false); input.AddMessageFilter(); input.KeyPressed += OnKeyPressed; if (!virtualJoy.vJoyEnabled()) { MessageBox.Show("vJoy is not installed. Exiting program..."); Close(); } }
public bool vJoyEnabled() { try { return(m_joystick != null && m_joystick.vJoyEnabled()); } catch (DllNotFoundException) { System.Windows.Forms.MessageBox.Show("Error, vJoyInterface.dll not found. Exiting...", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Environment.Exit(-1); return(false); } }
// functions ................... public void check() //check if virual joystick is enabled { if (!joystick1.vJoyEnabled()) { Debug.WriteLine("not enabled"); } else { Debug.WriteLine("Vendor: {0}\nProduct :{1}\nVersion Number:{2}\n", joystick1.GetvJoyManufacturerString(), joystick1.GetvJoyProductString(), joystick1.GetvJoySerialNumberString());; } }
private void ConnectToVirtualJoystick() { joystick = new vJoy(); if (!joystick.vJoyEnabled()) throw new Exception("Unable to connect to virtual joystick"); VjdStat joystickStatus = joystick.GetVJDStatus(JoystickId); if (joystickStatus != VjdStat.VJD_STAT_FREE) throw new Exception("State of Joystick is not free"); if (!joystick.AcquireVJD(JoystickId)) throw new Exception("Unable to acquire joystick"); joystick.GetVJDAxisMax(JoystickId, HID_USAGES.HID_USAGE_X, ref maxValue); joystick.ResetVJD(JoystickId); inputMultiplyer = maxValue / (maxDirectionVectorValue * 2d); // Max direction value }
static void Main() { Joystick = new vJoy(); if (!Joystick.vJoyEnabled()) { MessageBox.Show("vJoy is not enabled. You'll need to install vJoy before you can use this program.", "MIDIFeeder", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
/// <summary> /// Connect to a Joystick instance /// </summary> /// <param name="n">The joystick ID 1..16</param> /// <returns>True if successfull</returns> public bool Connect(int n) { if (Connected) { return(true); // already connected } try { if (!vJoy.isDllLoaded) { return(false); // ERROR exit DLL not loaded } if (n <= 0 || n > 16) { return(false); // ERROR exit invalid Joystick ID } m_jsId = (uint)n; m_joystick = new vJoy( ); if (!m_joystick.vJoyEnabled( )) { Disconnect( ); // cleanup return(false); // ERROR exit } // try to control.. Connected = m_joystick.isVJDExists(m_jsId); // exists? if (Connected) { Connected = m_joystick.AcquireVJD(m_jsId); // to use? } if (Connected) { bool r = m_joystick.ResetVJD(m_jsId); m_vJoystick = new vJoystick(m_joystick, m_jsId); // the one to use.. } else { m_jsId = 0; m_joystick = null; return(false); // ERROR exit } } catch { // wrong ... m_jsId = 0; m_joystick = null; } return(Connected); }
public void Start() { idVJoy = 1u; joystick = new vJoy(); var enabled = joystick.vJoyEnabled(); if (!enabled) { Console.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes."); return; } var vjdStatus = joystick.GetVJDStatus(idVJoy); Console.WriteLine(vjdStatus.ToString()); switch (vjdStatus) { case VjdStat.VJD_STAT_OWN: Console.WriteLine("vJoy Device {0} is already owned by this feeder\n", idVJoy); break; case VjdStat.VJD_STAT_FREE: Console.WriteLine("vJoy Device {0} is free\n", idVJoy); break; case VjdStat.VJD_STAT_BUSY: Console.WriteLine("vJoy Device {0} is already owned by another feeder\nCannot continue\n", idVJoy); return; case VjdStat.VJD_STAT_MISS: Console.WriteLine("vJoy Device {0} is not installed or disabled\nCannot continue\n", idVJoy); return; default: Console.WriteLine("vJoy Device {0} general error\nCannot continue\n", idVJoy); return; } acquired = joystick.AcquireVJD(idVJoy); if (!acquired) { Console.WriteLine("Failed to acquire vJoy device number {0}.\n", idVJoy); return; } Console.WriteLine("Acquired: vJoy device number {0}.\n", idVJoy); }