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(); }
public static void setJoystick(ref vJoy joystick, ControllerState input, uint joystickID, ControllerDeadZones deadZones) { bool res; var multiplier = 127; if (!deadZones.analogStick.inDeadZone(input.StickX, input.StickY)) { res = joystick.SetAxis(multiplier * input.StickX, joystickID, HID_USAGES.HID_USAGE_X); res = joystick.SetAxis(multiplier * (255 - input.StickY), joystickID, HID_USAGES.HID_USAGE_Y); } else { res = joystick.SetAxis(multiplier * 129, joystickID, HID_USAGES.HID_USAGE_X); res = joystick.SetAxis(multiplier * 129, joystickID, HID_USAGES.HID_USAGE_Y); } if (!deadZones.cStick.inDeadZone(input.CX, input.CY)) { res = joystick.SetAxis(multiplier * input.CX, joystickID, HID_USAGES.HID_USAGE_RX); res = joystick.SetAxis(multiplier * (255 - input.CY), joystickID, HID_USAGES.HID_USAGE_RY); } else { res = joystick.SetAxis(multiplier * 129, joystickID, HID_USAGES.HID_USAGE_RX); res = joystick.SetAxis(multiplier * 129, joystickID, HID_USAGES.HID_USAGE_RY); } if (!deadZones.LTrigger.inDeadZone(input.LAnalog)) { res = joystick.SetAxis(multiplier * input.LAnalog, joystickID, HID_USAGES.HID_USAGE_Z); } else { res = joystick.SetAxis(0, joystickID, HID_USAGES.HID_USAGE_Z); } if (!deadZones.RTrigger.inDeadZone(input.RAnalog)) { res = joystick.SetAxis(multiplier * input.RAnalog, joystickID, HID_USAGES.HID_USAGE_RZ); } else { res = joystick.SetAxis(0, joystickID, HID_USAGES.HID_USAGE_RZ); } //dpad button mode for DDR pad support res = joystick.SetBtn(input.DUp, joystickID, 9); res = joystick.SetBtn(input.DDown, joystickID, 10); res = joystick.SetBtn(input.DLeft, joystickID, 11); res = joystick.SetBtn(input.DRight, joystickID, 12); //buttons res = joystick.SetBtn(input.A, joystickID, 1); res = joystick.SetBtn(input.B, joystickID, 2); res = joystick.SetBtn(input.X, joystickID, 3); res = joystick.SetBtn(input.Y, joystickID, 4); res = joystick.SetBtn(input.Z, joystickID, 5); res = joystick.SetBtn(input.RDigital, joystickID, 6); res = joystick.SetBtn(input.LDigital, joystickID, 7); res = joystick.SetBtn(input.Start, joystickID, 8); }
private vJoy initVjoy(uint id) { var joystick = new vJoy(); var iReport = new vJoy.JoystickState(); // Get the state of the requested device VjdStat status = joystick.GetVJDStatus(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: * MessageBox.Show(string.Format("vJoy Device {0} is already owned by another feeder\nCannot continue\n", id)); * return joystick; * case VjdStat.VJD_STAT_MISS: * MessageBox.Show(string.Format("vJoy Device {0} is not installed or disabled\nCannot continue\n", id)); * return joystick; * default: * MessageBox.Show(string.Format("vJoy Device {0} general error\nCannot continue\n", id)); * return joystick; * }*/ bool AxisX = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_X); if (joystick.AcquireVJD(id) == false) { MessageBox.Show("Could not acquire vJoy " + id); } Console.WriteLine(AxisX); return(joystick); }
static void Main(string[] args) { Console.WriteLine("MIDI-to-VJoy converter by Åke Wallebom"); Console.Error.WriteLine("Button Mapping: <midi channel>,<data1 min>-<data1 max>,<joyid>,<buttonoffset> or" + Environment.NewLine + "Axis Mapping: <midi channel>,<data1>,<joyid>,<axis (x,y,z,rx,ry,rz,sl0,sl1)>" + Environment.NewLine + "E.g. 0,23-31,1,1 0,33-41,1,11 0,14,1,x 0,15,1,y 0,16,1,z 0,17,1,rx 0,18,1,ry 0,19,1,rz 0,20,1,sl0 0,21,1,sl1" + Environment.NewLine); stat_mapping = new Mapping(); if (!ParseMappings(args, stat_mapping)) { Console.Error.WriteLine("Command-line argument invalid"); return; } stat_vJoy = InitVJoy(); if (stat_vJoy == null) { Console.Error.WriteLine("Couldn't init vjoy driver"); return; } foreach (var joyId in stat_mapping.JoyIds) { if (!InitVJoyById(stat_vJoy, joyId)) { Console.Error.WriteLine("Couldn't init vjoy id = " + joyId); return; } } StartMidi(); Console.WriteLine("WinMidi2VJoy Running..."); }
public void ForceReinitJoystick() { try { lock (lockObj) { if (VirtualJoystick != null) { VirtualJoystick.RelinquishVJD(JoystickID); } VirtualJoystick = new vJoy(); } } catch (Exception ex) { #if DEBUG Console.WriteLine(ex.ToString()); #endif } try { InitJoystick(); } catch (Exception ex) { #if DEBUG Console.WriteLine(ex.ToString()); #endif } }
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!"); }
public vJoystick(vJoy joy, uint jID) { m_joy = joy; Index = jID; m_nButtons = m_joy.GetVJDButtonNumber(Index); m_nPov = m_joy.GetVJDDiscPovNumber(Index); m_prodS = m_joy.GetvJoyProductString( ); m_hasX = GetState(HID_USAGES.HID_USAGE_X); m_hasY = GetState(HID_USAGES.HID_USAGE_Y); m_hasZ = GetState(HID_USAGES.HID_USAGE_Z); m_hasRX = GetState(HID_USAGES.HID_USAGE_RX); m_hasRY = GetState(HID_USAGES.HID_USAGE_RY); m_hasRZ = GetState(HID_USAGES.HID_USAGE_RZ); m_hasSL1 = GetState(HID_USAGES.HID_USAGE_SL0); m_hasSL2 = GetState(HID_USAGES.HID_USAGE_SL1); for (int i = 1; i <= m_nPov; i++) { m_hasPov[i] = GetState(HID_USAGES.HID_USAGE_POV, i); } for (int i = 1; i <= m_nButtons; i++) { m_hasBtn[i] = GetState(HID_USAGES.HID_USAGE_WHL, i); // Use WHL as button qualifier... } }
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); }
public JoystickOutput() { int id = 1; ID = (uint)id; joy = initVjoy(ID); }
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 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 MainWindow() { InitializeComponent(); this.xInputService = new XInputService(); this.vjoy = new vJoy(); }
public RLocalVJoy() { vjoy = new vJoy(); ValidateHost(); //vJoy.JoystickState joystickState = new vJoy.JoystickState(); }
public vJoyFeeder() { NbButtons = -1; // Create one joystick object and a position structure. Joystick = new vJoy(); Report = new vJoy.JoystickState(); FFBReceiver = new vJoyFFBReceiver(); // Prepare list of vJoy's axes configuration. This is done // only one time after retreiving vJoy's information // Fill all axes HIDAxesInfo.Clear(); foreach (HID_USAGES toBeTested in Enum.GetValues(typeof(HID_USAGES))) { // Skip POV if (toBeTested == HID_USAGES.HID_USAGE_POV) { continue; } var name = toBeTested.ToString().Replace("HID_USAGE_", ""); var axisinfo = new vJoyAxisInfos(); axisinfo.HID_Usage = toBeTested; axisinfo.Name = name; HIDAxesInfo.Add(axisinfo); } // Fill OnlyUsedInfo by copying reference from AllAxesInfo once done ConfiguredvJoyAxes.Clear(); }
public JoystickHelper() { keys = new Keys(); joystick = new vJoy(); iReport = new vJoy.JoystickState(); long lAxisMax = 0; joystick.GetVJDAxisMax(id, HID_USAGES.HID_USAGE_X, ref lAxisMax); axisMax = (int)lAxisMax; string error = null; int nDevices = 0; for (uint i = 1; i <= 16; i++) { if ((error = vjoyhelper.setup(joystick, i)) != null) { // Assume no more devices are set up correctly break; } nDevices++; } for (int i = 1; i <= nDevices; i++) { availJoy.Add(i); } numberOfDevices = nDevices; }
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); }
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 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 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"); } }
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); }
public override void HandleControl(string line, vJoy joystick, uint deviceId) { if (line == string.Format("{0}\r", PushMsg) || line == string.Format("{0}\r", ReleaseMsg)) { joystick.SetBtn(true, deviceId, Button); joystick.SetBtn(false, deviceId, Button); } }
public IWriter Create(Identifier id) { var device = new vJoy(); device.AcquireVJD(id.Id); device.ResetVJD(id.Id); return(new Writer(id, device)); }
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 vJoyVibrate(vJoy parVJoy) { joystick = parVJoy; for (int x = 1; x <= SCPConstants.MAX_XINPUT_DEVICES; x++) { devices[x - 1] = new FFBDevice(); devices[x - 1].ClearBlocks(); } }
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); }
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; }
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); }
public static INFO_STRUCT GetControllerInfo(vJoy controller, uint id) { INFO_STRUCT temp = new INFO_STRUCT(); if (valid_controller_info(controller, id, ref temp)) { return(temp); } return(null); }
/// <summary> /// Creates a new instance of joystick /// </summary> /// <param name="joyId">Id of simulated joystick between (1,16). It have to exists in system before the invokation.</param> public JoyControl(uint joyId) { if (!joyId.Between(1, 16, true)) { throw new Exception(String.Format("Illegal device ID {0}", joyId)); } IsBusy = false; _joyId = joyId; _joystick = new vJoy(); }