void OnDisable() { if (vJoyStatus == VJoyStatus.Ready) { vjoy.RelinquishVJD(deviceId); vjoy.RelinquishVJD(secondaryDeviceId); SetStatus(VJoyStatus.Unknown); } }
public void Stop(bool[] parSelectedPads, DeviceManagement devManLevel) { for (uint dsID = 1; dsID <= SCPConstants.MAX_XINPUT_DEVICES; dsID++) { if (parSelectedPads[dsID - 1]) { uint id = GetvjFromDS(dsID); try { if (vibrationCore != null) { vibrationCore.FfbStop(id); vibrationCore = null; } joystick.RelinquishVJD(id); } catch { //if this ever produces an error } } } if ((devManLevel & DeviceManagement.vJoy_Device) == DeviceManagement.vJoy_Device) { EnableVJoy(false); } }
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 Disconnect() { if (_joystick == null) { throw new PTGenericException("Feeder is already disconnected."); } _joystick.RelinquishVJD(_deviceId); }
public void Stop() { if (acquired) { Throttle(0); Direction(0); joystick.RelinquishVJD(idVJoy); } }
public void ReleaseDevice() { if (bDeviceAcquired) { m_joystick.ResetVJD(m_vJoyID); m_joystick.RelinquishVJD(m_vJoyID); bDeviceAcquired = false; } }
// Demo callback function // Called with every FFB packet that is sent to a vJoy device // Must be registered using function FfbRegisterGenCB() private void TesterForm_FormClosed(object sender, FormClosedEventArgs e) { VjdStat status; // Don't use (Too slow) - joystick.ResetAll(); joystick.ResetVJD(id); status = joystick.GetVJDStatus(id); joystick.RelinquishVJD(id); status = joystick.GetVJDStatus(id); }
private void OnDisable() { if (vJoyStatus != VJoyStatus.Ready) { return; } vjoy.RelinquishVJD(deviceId); SetStatus(VJoyStatus.Unknown); }
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); }
/*void checkvJoyDeviceInputs() { * uint vjid = (uint)joyIDSelector.Value; * * setMLDataAsync(0, maplistsub.Available, joy.GetVJDAxisExist(vjid, HID_USAGES.HID_USAGE_X) ? "Yes" : "No"); * setMLDataAsync(1, maplistsub.Available, joy.GetVJDAxisExist(vjid, HID_USAGES.HID_USAGE_Y) ? "Yes" : "No"); * setMLDataAsync(2, maplistsub.Available, joy.GetVJDAxisExist(vjid, HID_USAGES.HID_USAGE_Z) ? "Yes" : "No"); * setMLDataAsync(3, maplistsub.Available, joy.GetVJDAxisExist(vjid, HID_USAGES.HID_USAGE_RX) ? "Yes" : "No"); * setMLDataAsync(4, maplistsub.Available, joy.GetVJDAxisExist(vjid, HID_USAGES.HID_USAGE_RY) ? "Yes" : "No"); * setMLDataAsync(5, maplistsub.Available, joy.GetVJDAxisExist(vjid, HID_USAGES.HID_USAGE_RZ) ? "Yes" : "No"); * setMLDataAsync(6, maplistsub.Available, joy.GetVJDAxisExist(vjid, HID_USAGES.HID_USAGE_SL0) ? "Yes" : "No"); * setMLDataAsync(7, maplistsub.Available, joy.GetVJDAxisExist(vjid, HID_USAGES.HID_USAGE_SL1) ? "Yes" : "No"); * }*/ void vJoyToggle() { if (checkStat(stat.VJDevReady) & !checkStat(stat.VJDevAttached)) { if (joy.AcquireVJD((uint)joyIDSelector.Value)) { setStat(stat.VJDevAttached); joyIDSelector.Enabled = false; btnJoyAttach.Text = "Detach"; } } else { joy.RelinquishVJD((uint)joyIDSelector.Value); setStat(stat.VJDevAttached, 0); joyIDSelector.Enabled = true; btnJoyAttach.Text = "Attach"; } refreshStatusIcons(stat.VJOK); }
/// <summary> /// Last one close the door... /// /// Disconnect the Joystick system /// </summary> public void Disconnect() { if (Connected) { m_joystick.ResetVJD(m_jsId); m_joystick.RelinquishVJD(m_jsId); } Connected = false; m_jsId = 0; m_joystick = null; }
/// <summary> /// Disconnects the current instance of joystick from currently bound virtual device. /// </summary> /// <returns>The success of the disconnect operation</returns> public bool Disconnect() { if (!IsBusy) { throw new Exception("You cannot disconnect a not connected joystick."); } _joystick.RelinquishVJD(_joyId); IsBusy = false; return(true); }
private void vJoyBox_CheckedChanged(object sender, EventArgs e) { if (currentHandle != new IntPtr(0)) { if (!keyboards[currentHandle].vJoyEnabled) { bool acquiredDevice = false; for (uint i = 1; i <= 16; i++) { if (virtualJoy.GetVJDStatus(i) == VjdStat.VJD_STAT_FREE) { virtualJoy.AcquireVJD(i); keyboards[currentHandle].vJoyEnabled = true; keyboards[currentHandle].vJoyId = i; acquiredDevice = true; virtualJoy.SetAxis(16384, keyboards[currentHandle].vJoyId, HID_USAGES.HID_USAGE_X); virtualJoy.SetAxis(16384, keyboards[currentHandle].vJoyId, HID_USAGES.HID_USAGE_Y); virtualJoy.SetAxis(16384, keyboards[currentHandle].vJoyId, HID_USAGES.HID_USAGE_RX); virtualJoy.SetAxis(16384, keyboards[currentHandle].vJoyId, HID_USAGES.HID_USAGE_RY); virtualJoy.SetAxis(1, keyboards[currentHandle].vJoyId, HID_USAGES.HID_USAGE_Z); MessageBox.Show($"Acquired vJoy device {i}."); break; } } if (!acquiredDevice) { MessageBox.Show("vJoy device acquisition failed: There are no free devices."); vJoyBox.CheckedChanged -= vJoyBox_CheckedChanged; vJoyBox.Checked = false; vJoyBox.CheckedChanged += vJoyBox_CheckedChanged; } } else { virtualJoy.RelinquishVJD(keyboards[currentHandle].vJoyId); MessageBox.Show($"Relinquished vJoy device {keyboards[currentHandle].vJoyId}."); keyboards[currentHandle].vJoyId = 17; keyboards[currentHandle].vJoyEnabled = false; } } else { MessageBox.Show("You have to select a Keyboard by clicking \"Detect Keyboard\" and pressing any key on the desired keyboard before changing settings."); vJoyBox.CheckedChanged -= vJoyBox_CheckedChanged; vJoyBox.Checked = false; vJoyBox.CheckedChanged += vJoyBox_CheckedChanged; } }
private void GamePad() { try { client = new UdpClient(DATA_PORT); IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, DATA_PORT); vJoy.JoystickState joystickState = new vJoy.JoystickState(); joystickState.bDevice = id; while (true) { byte[] data = client.Receive(ref endPoint); // TODO: Remove? /*if(data.Length < 32) { * continue; * }*/ joystickState.AxisZRot = BitConverter.ToUInt16(data, 0); joystickState.AxisXRot = BitConverter.ToUInt16(data, 2); joystickState.AxisYRot = BitConverter.ToUInt16(data, 4); joystickState.AxisZ = BitConverter.ToUInt16(data, 6); joystickState.AxisX = BitConverter.ToUInt16(data, 8); joystickState.AxisY = BitConverter.ToUInt16(data, 10); joystickState.Slider = BitConverter.ToUInt16(data, 12); joystickState.Dial = BitConverter.ToUInt16(data, 14); joystickState.Buttons = BitConverter.ToUInt32(data, 16); joystickState.ButtonsEx1 = BitConverter.ToUInt32(data, 20); joystickState.ButtonsEx2 = BitConverter.ToUInt32(data, 24); joystickState.ButtonsEx3 = BitConverter.ToUInt32(data, 28); joystick.UpdateVJD(id, ref joystickState); } } catch { Debug.WriteLine("Receive loop exit"); } joystick.RelinquishVJD(id); }
private void JoystickChangedListener(JoystickChangedEventArgs args) { if (args == null) { return; } var deviceId = (uint)args.Id; if (!deviceId.Equals(Convert.ToUInt32(CurrentDevice.Id))) { var vJoy = new vJoy(); vJoy.RelinquishVJD(Convert.ToUInt32(CurrentDevice.Id)); CurrentDevice = new JoystickInformation(args.Id, args.Name, args.Guid); } }
public static void Feed(vJoy vjoy, Configuration config, EDStatusMonitor monitor) { // copy configuration and status to prevent changes from taking effect during the feed process uint deviceId = (uint)config.DeviceId; Dictionary <string, int> buttonIds = config.ButtonConfigurationCopy; Dictionary <string, bool> statusFlags = monitor.StatusCopy; if (!vjoy.AcquireVJD(deviceId)) { throw new ButtonFeederException($"vJoy error: Unable to acquire vJoy device #{deviceId}"); } foreach (string flag in statusFlags.Keys) { bool status = statusFlags[flag]; char buttonId = (char)buttonIds[flag]; vjoy.SetBtn(status, deviceId, buttonId); } vjoy.RelinquishVJD(deviceId); }
public void Dispose() { joystick.RelinquishVJD(Index); }
public void freejoy() { // free and reset all joystick controls joystick1.ResetVJD(joyid); joystick1.RelinquishVJD(joyid); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { Program._shouldExit = true; joystick.RelinquishVJD(id); }
public void Clear() { _joystick.RelinquishVJD(_id); }
/// <summary> /// Release a previously acquired vJoy device ID /// </summary> public void Release() { Joystick.RelinquishVJD(vJoyDevID); }
public void Dispose() { joystick.RelinquishVJD(jID); joystick = null; }
public override void Release() { _reset(); joystick.RelinquishVJD((uint)id); }
public void stop() { device.RelinquishVJD(id); }
public void ReleaseController() { joystick.RelinquishVJD(id); context.logmMssage("Released VJOY"); }
public void Release() { Joystick.RelinquishVJD(joyID); }
public void relinquish() { initAxes(); joystick.RelinquishVJD(id); }
/// <summary> /// 念のため実装 /// </summary> public void Dispose() { joystick.RelinquishVJD(rID); }
public void Stop() { _joystick.RelinquishVJD(_deviceId); }
public void RelinquishDevice(uint deviceID) { joystick.RelinquishVJD(deviceID); }