コード例 #1
0
        public Dictionary <string, string> GetInfo() // Just for testing
        {
            Dictionary <string, string> info = new Dictionary <string, string>();

            if (Vjoy.vJoyEnabled())
            {
                info["Vendor"]  = Vjoy.GetvJoyManufacturerString();
                info["Product"] = Vjoy.GetvJoyProductString();
                info["Serial"]  = Vjoy.GetvJoyVersion().ToString(); // Why are serial and version backwards??
                info["Version"] = Vjoy.GetvJoySerialNumberString();

                UInt32 DllVer = 0, DrvVer = 0;
                info["Driver Match"]      = Vjoy.DriverMatch(ref DllVer, ref DrvVer).ToString();
                info["Number of Buttons"] = Vjoy.GetVJDButtonNumber(_vJoyNumber).ToString();

                uint    id     = 1; // First device is 1 (not 0) - there is also no way to check for the number of devices (at least that I can find).
                VjdStat status = Vjoy.GetVJDStatus(id);
                switch (status)
                {
                case VjdStat.VJD_STAT_OWN:
                    info["Status"] = "vJoy Device " + _vJoyNumber + " is already owned by this feeder";
                    break;

                case VjdStat.VJD_STAT_FREE:
                    info["Status"] = "vJoy Device " + _vJoyNumber + " is free";
                    break;

                case VjdStat.VJD_STAT_BUSY:
                    info["Status"] = "vJoy Device " + _vJoyNumber + " is already owned by another feeder";
                    break;

                case VjdStat.VJD_STAT_MISS:
                    info["Status"] = "vJoy Device " + _vJoyNumber + "  is not installed or disabled";
                    break;

                default:
                    info["Status"] = "vJoy Device " + _vJoyNumber + " general error";
                    break;
                }
            }
            else
            {
                info["Status"] = "vJoy driver not enabled: Failed Getting vJoy attributes";
            }
            return(info);
        }
コード例 #2
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();
        }