コード例 #1
0
 void OnDisable()
 {
     if (vJoyStatus == VJoyStatus.Ready)
     {
         vjoy.RelinquishVJD(deviceId);
         vjoy.RelinquishVJD(secondaryDeviceId);
         SetStatus(VJoyStatus.Unknown);
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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
            }
        }
コード例 #4
0
ファイル: Feeder.cs プロジェクト: IronhideIvan/pass-thru
        public void Disconnect()
        {
            if (_joystick == null)
            {
                throw new PTGenericException("Feeder is already disconnected.");
            }

            _joystick.RelinquishVJD(_deviceId);
        }
コード例 #5
0
 public void Stop()
 {
     if (acquired)
     {
         Throttle(0);
         Direction(0);
         joystick.RelinquishVJD(idVJoy);
     }
 }
コード例 #6
0
ファイル: vJoyManager.cs プロジェクト: xuxiandi/XJoy
 public void ReleaseDevice()
 {
     if (bDeviceAcquired)
     {
         m_joystick.ResetVJD(m_vJoyID);
         m_joystick.RelinquishVJD(m_vJoyID);
         bDeviceAcquired = false;
     }
 }
コード例 #7
0
        // 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);
        }
コード例 #8
0
        private void OnDisable()
        {
            if (vJoyStatus != VJoyStatus.Ready)
            {
                return;
            }

            vjoy.RelinquishVJD(deviceId);
            SetStatus(VJoyStatus.Unknown);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: AndersMalmgren/VJoyFfbTest
        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);
        }
コード例 #10
0
ファイル: main.cs プロジェクト: Seriy-A/SerialJoy
        /*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);
        }
コード例 #11
0
 /// <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;
 }
コード例 #12
0
        /// <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);
        }
コード例 #13
0
        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;
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
        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);
        }
コード例 #17
0
 public void Dispose()
 {
     joystick.RelinquishVJD(Index);
 }
コード例 #18
0
ファイル: MainWindow.xaml.cs プロジェクト: lalitsom/MultiKeys
 public void freejoy()
 {  // free and reset all joystick controls
     joystick1.ResetVJD(joyid);
     joystick1.RelinquishVJD(joyid);
 }
コード例 #19
0
ファイル: Form1.cs プロジェクト: katzenbaer/twitchplaysyellow
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     Program._shouldExit = true;
     joystick.RelinquishVJD(id);
 }
コード例 #20
0
ファイル: vJoyWrapper.cs プロジェクト: chuoique/VjoyWrapper
 public void Clear()
 {
     _joystick.RelinquishVJD(_id);
 }
コード例 #21
0
 /// <summary>
 /// Release a previously acquired vJoy device ID
 /// </summary>
 public void Release()
 {
     Joystick.RelinquishVJD(vJoyDevID);
 }
コード例 #22
0
ファイル: VJoyFeeder.cs プロジェクト: Romulus968/iDash
 public void Dispose()
 {
     joystick.RelinquishVJD(jID);
     joystick = null;
 }
コード例 #23
0
 public override void Release()
 {
     _reset();
     joystick.RelinquishVJD((uint)id);
 }
コード例 #24
0
 public void stop()
 {
     device.RelinquishVJD(id);
 }
コード例 #25
0
 public void ReleaseController()
 {
     joystick.RelinquishVJD(id);
     context.logmMssage("Released VJOY");
 }
コード例 #26
0
 public void Release()
 {
     Joystick.RelinquishVJD(joyID);
 }
コード例 #27
0
 public void relinquish()
 {
     initAxes();
     joystick.RelinquishVJD(id);
 }
コード例 #28
0
 /// <summary>
 /// 念のため実装
 /// </summary>
 public void Dispose()
 {
     joystick.RelinquishVJD(rID);
 }
コード例 #29
0
 public void Stop()
 {
     _joystick.RelinquishVJD(_deviceId);
 }
コード例 #30
0
 public void RelinquishDevice(uint deviceID)
 {
     joystick.RelinquishVJD(deviceID);
 }