예제 #1
0
파일: TesterForm.cs 프로젝트: evilC/vGen
        // Demo callback function
        // Called with every FFB packet that is sent to a vGen 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);
        }
 static void OnProcessExit(object sender, EventArgs e)
 {
     if (id > 0 && id <= 16)
     {
         if (joystick != null)
         {
             if (joystick.isVBusExist() == 0)
             {
                 for (int i = 1; i < 5; i++)
                 {
                     bool exists = false;
                     joystick.isControllerPluggedIn((uint)i, ref exists);
                     if (exists)
                     {
                         joystick.UnPlugForce((uint)i);
                     }
                 }
             }
             joystick.RelinquishVJD(id);
         }
     }
 }
예제 #3
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                //if (disposing) { }

                if (Initialized)   // Must release the controller
                //vJoy.RelinquishDev ((int) handle);
                {
                    vJoy.RelinquishVJD(handle);
                }

                disposedValue = true;
            }
        }
        private bool vJoySetup()
        {
            joystick = new vGen();
            iReport  = new vGen.JoystickState();
            if (id <= 0 || id > 16)
            {
                consoleOut("Illegal device ID " + id + "!");
            }
            if (!joystick.vJoyEnabled())
            {
                consoleOut("vJoy driver not enabled: Failed Getting vJoy attributes.");
                return(false);
            }
            else
            {
                consoleOut("Vendor: " + joystick.GetvJoyManufacturerString() + "\nProduct: " + joystick.GetvJoyProductString() + "\nVersion Number: " + joystick.GetvJoySerialNumberString() + ".");
            }
            VjdStat st = joystick.GetVJDStatus(id);

            switch (st)
            {
            case VjdStat.VJD_STAT_OWN:
                consoleOut("vJoy Device " + id + " is already owned by this feeder.");
                break;

            case VjdStat.VJD_STAT_FREE:
                consoleOut("vJoy Device " + id + " is free.");
                break;

            case VjdStat.VJD_STAT_BUSY:
                joystick.RelinquishVJD(id);
                consoleOut("vJoy Device " + id + " is already owned by another feeder - Trying to recover.");
                return(false);

            case VjdStat.VJD_STAT_MISS:
                consoleOut("vJoy Device " + id + " is not installed or disabled - Cannot continue.");
                return(false);

            default:
                consoleOut("vJoy Device " + id + " general error - Cannot continue.");
                return(false);
            }
            ;

            st = joystick.GetVJDStatus(id);

            if ((st == VjdStat.VJD_STAT_OWN) || ((st == VjdStat.VJD_STAT_FREE) && (!joystick.AcquireVJD(id))))
            {
                consoleOut("Failed to acquire vJoy device number " + id + ".");
            }
            else
            {
                consoleOut("Acquired vJoy device number " + id + ".");
            }
            int    nButtons = joystick.GetVJDButtonNumber(id);
            UInt32 DllVer = 0, DrvVer = 0;
            bool   match = joystick.DriverMatch(ref DllVer, ref DrvVer);

            if (match)
            {
                consoleOut("Version of Driver Matches DLL Version (" + DllVer + ")");
            }
            else
            {
                consoleOut("Version of Driver (" + DrvVer + ") does NOT match DLL Version (" + DllVer + ")");
            }
            joystick.ResetVJD(id);
            for (uint i = 1; i <= nButtons; i++)
            {
                consoleOut(i + ") OFF: " + joystick.SetBtn(false, id, i));
            }
            consoleOut("\nvJoy setup completed succesfully!\n");
            return(true);
        }