コード例 #1
0
ファイル: vJoyButton.cs プロジェクト: ashupp/Streamdeck-vJoy
        public override void KeyPressed(KeyPayload payload)
        {
            if (settings.triggerPush || settings.triggerPushAndRelease)
            {
                if (_virtualJoystick == null || !_virtualJoystickAcquired)
                {
                    _virtualJoystick.AcquireVJD(Convert.ToUInt32(settings.vJoyDeviceId));
                }


                if (settings.vJoyElementType == "btn")
                {
                    // Es ist ein Button
                    _virtualJoystick.SetBtn(true, Convert.ToUInt32(settings.vJoyDeviceId), Convert.ToUInt32(settings.vJoyButtonId));
                }
                else
                {
                    // Es ist eine Achse
                    var        axisValue = 0;
                    HID_USAGES theAxis   = getAxisNameByString(settings.vJoyElementType);


                    if (settings.setToMin)
                    {
                        axisValue = GetJoystickAxisMinValue(theAxis);
                    }
                    else if (settings.setToMax)
                    {
                        axisValue = GetJoystickAxisMaxValue(theAxis);
                    }
                    else if (settings.setToCenter)
                    {
                        axisValue = GetJoystickAxisCenter(theAxis);
                    }
                    else if (settings.setToCustom)
                    {
                        axisValue = Convert.ToInt32(settings.setToCustomValue);
                    }
                    else if (settings.setToStepUp)
                    {
                        axisValue = stepUpAxisValue(theAxis, settings.setStepUp);
                    }
                    else if (settings.setToStepDown)
                    {
                        axisValue = stepDownAxisValue(theAxis, settings.setStepDown);
                    }

                    setAxisValue(axisValue, theAxis);
                    axisValues[theAxis] = axisValue;
                }
                _virtualJoystick?.RelinquishVJD(Convert.ToUInt32(settings.vJoyDeviceId));
            }
        }
コード例 #2
0
 private void EnsureAcquireJoystick()
 {
     if (settings.vJoyDeviceId != "")
     {
         _virtualJoystick.AcquireVJD(Convert.ToUInt32(settings.vJoyDeviceId));
     }
 }
コード例 #3
0
        public Joystick()
        {
            m_Interface = new vJoyInterfaceWrap.vJoy();

            try
            {
                if (m_Interface.AcquireVJD(1))
                {
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #4
0
        internal void ApplySettings()
        {
            if (settings.vJoyDeviceId != "")
            {
                uint updatedDeviceId = Convert.ToUInt32(settings.vJoyDeviceId);

                if (updatedDeviceId != vJoyDeviceId)
                {
                    joystick.RelinquishVJD(vJoyDeviceId);
                    vJoyDeviceId = updatedDeviceId;
                    joystick.AcquireVJD(vJoyDeviceId);
                }

                vJoyButtonIds = Array.ConvertAll(RemoveExtraText(settings.vJoyButtonIds).Split(comma, StringSplitOptions.RemoveEmptyEntries), Convert.ToUInt32);

                Connection.SetSettingsAsync(JObject.FromObject(settings));
            }
        }
コード例 #5
0
        public Vcontroller(uint vJoyNumber, int updateRate = 20)
        {
            _vJoyNumber   = vJoyNumber;
            Vjoy          = new vJoyInterfaceWrap.vJoy();
            JoystickState = new vJoyInterfaceWrap.vJoy.JoystickState();
            VjdStat status = Vjoy.GetVJDStatus(_vJoyNumber);

            if (status == VjdStat.VJD_STAT_OWN || status == VjdStat.VJD_STAT_FREE)
            {
                Vjoy.AcquireVJD(_vJoyNumber);
            }
            else
            {
                throw (new Exception("Could not acquire Vjoy"));
            }
            Vjoy.ResetVJD(_vJoyNumber);
            _buttonCount = Vjoy.GetVJDButtonNumber(_vJoyNumber);
            _initButtons();
            _initDiscPovs();
            _initAxes();
            _initJoystickState();
            UpdateRate = updateRate;
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: dabeezor/test
        public MainForm()
        {
            InitializeComponent();

            base.Disposed += OnDisposed;

            try
            {
                m_Interface = new vJoyInterfaceWrap.vJoy();

                // Get the driver attributes (Vendor ID, Product ID, Version Number)
                if (!m_Interface.vJoyEnabled())
                {
                    Console.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes.\n");
                    return;
                }
                else
                {
                    Console.WriteLine("v{0}\nVendor: {1}\nProduct :{2}\nVersion Number:{3}\n", m_Interface.GetvJoyVersion(), m_Interface.GetvJoyManufacturerString(), m_Interface.GetvJoyProductString(), m_Interface.GetvJoySerialNumberString());
                }



                // Check which axes are supported
                bool AxisX  = m_Interface.GetVJDAxisExist(m_Id, HID_USAGES.HID_USAGE_X);
                bool AxisY  = m_Interface.GetVJDAxisExist(m_Id, HID_USAGES.HID_USAGE_Y);
                bool AxisZ  = m_Interface.GetVJDAxisExist(m_Id, HID_USAGES.HID_USAGE_Z);
                bool AxisRX = m_Interface.GetVJDAxisExist(m_Id, HID_USAGES.HID_USAGE_RX);
                bool AxisRZ = m_Interface.GetVJDAxisExist(m_Id, HID_USAGES.HID_USAGE_RZ);

                // Get the number of buttons and POV Hat switchessupported by this vJoy device
                int nButtons      = m_Interface.GetVJDButtonNumber(m_Id);
                int ContPovNumber = m_Interface.GetVJDContPovNumber(m_Id);
                int DiscPovNumber = m_Interface.GetVJDDiscPovNumber(m_Id);

                // Spit out the details
                Console.WriteLine(string.Format("Device[{0}]: Buttons={1}; DiscPOVs:{2}; ContPOVs:{3}", m_Id, nButtons, ContPovNumber, DiscPovNumber));



                // Write access to vJoy Device - Basic
                VjdStat status = m_Interface.GetVJDStatus(m_Id);

                // Acquire the target
                if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!m_Interface.AcquireVJD(m_Id))))
                {
                    Console.WriteLine(string.Format("Failed to acquire vJoy device number {0}.", m_Id));
                }
                else
                {
                    Console.WriteLine(string.Format("Acquired: vJoy device number {0}.", m_Id));

                    m_Interface.ResetAll();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            m_Timer.Tick    += OnTick;
            m_Timer.Interval = 2000;
            m_Timer.Start();
        }