GetVJDAxisMin() public method

public GetVJDAxisMin ( UInt32 rID, HID_USAGES Axis, long &Min ) : bool
rID UInt32
Axis HID_USAGES
Min long
return bool
コード例 #1
0
ファイル: VJoyManager.cs プロジェクト: Xtreamer/WiiJoy
        public void Initialize()
        {
            // Create one joystick object and a position structure.
            joystick = new vJoy();
            iReport = new vJoy.JoystickState();

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

            // Get the state of the requested device
            VjdStat status = joystick.GetVJDStatus(deviceId);
            switch (status)
            {
                case VjdStat.VJD_STAT_OWN:
                    Console.WriteLine("vJoy Device {0} is already owned by this feeder\n", deviceId);
                    break;
                case VjdStat.VJD_STAT_FREE:
                    Console.WriteLine("vJoy Device {0} is free\n", deviceId);
                    break;
                case VjdStat.VJD_STAT_BUSY:
                    Console.WriteLine("vJoy Device {0} is already owned by another feeder\nCannot continue\n", deviceId);
                    return;
                case VjdStat.VJD_STAT_MISS:
                    Console.WriteLine("vJoy Device {0} is not installed or disabled\nCannot continue\n", deviceId);
                    return;
                default:
                    Console.WriteLine("vJoy Device {0} general error\nCannot continue\n", deviceId);
                    return;
            };

            // Check which axes are supported
            bool AxisX = joystick.GetVJDAxisExist(deviceId, HID_USAGES.HID_USAGE_X);
            bool AxisY = joystick.GetVJDAxisExist(deviceId, HID_USAGES.HID_USAGE_Y);
            bool AxisZ = joystick.GetVJDAxisExist(deviceId, HID_USAGES.HID_USAGE_Z);
            bool AxisRX = joystick.GetVJDAxisExist(deviceId, HID_USAGES.HID_USAGE_RX);
            bool AxisRZ = joystick.GetVJDAxisExist(deviceId, HID_USAGES.HID_USAGE_RZ);
            // Get the number of buttons and POV Hat switchessupported by this vJoy device
            int nButtons = joystick.GetVJDButtonNumber(deviceId);
            int ContPovNumber = joystick.GetVJDContPovNumber(deviceId);
            int DiscPovNumber = joystick.GetVJDDiscPovNumber(deviceId);

            // Print results
            Console.WriteLine("\nvJoy Device {0} capabilities:\n", deviceId);
            Console.WriteLine("Numner of buttons\t\t{0}\n", nButtons);
            Console.WriteLine("Numner of Continuous POVs\t{0}\n", ContPovNumber);
            Console.WriteLine("Numner of Descrete POVs\t\t{0}\n", DiscPovNumber);
            Console.WriteLine("Axis X\t\t{0}\n", AxisX ? "Yes" : "No");
            Console.WriteLine("Axis Y\t\t{0}\n", AxisX ? "Yes" : "No");
            Console.WriteLine("Axis Z\t\t{0}\n", AxisX ? "Yes" : "No");
            Console.WriteLine("Axis Rx\t\t{0}\n", AxisRX ? "Yes" : "No");
            Console.WriteLine("Axis Rz\t\t{0}\n", AxisRZ ? "Yes" : "No");

            // Test if DLL matches the driver
            UInt32 DllVer = 0, DrvVer = 0;
            bool match = joystick.DriverMatch(ref DllVer, ref DrvVer);
            if (match)
                Console.WriteLine("Version of Driver Matches DLL Version ({0:X})\n", DllVer);
            else
                Console.WriteLine("Version of Driver ({0:X}) does NOT match DLL Version ({1:X})\n", DrvVer, DllVer);

            System.Threading.Thread.Sleep(500);

            // Acquire the target
            if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!joystick.AcquireVJD(deviceId))))
            {
                Console.WriteLine("Failed to acquire vJoy device number {0}.\n", deviceId);
                return;
            }
            else
                Console.WriteLine("Acquired: vJoy device number {0}.\n", deviceId);

            joystick.GetVJDAxisMax(deviceId, HID_USAGES.HID_USAGE_X, ref xMaxVal);
            joystick.GetVJDAxisMin(deviceId, HID_USAGES.HID_USAGE_X, ref xMinVal);
            joystick.GetVJDAxisMax(deviceId, HID_USAGES.HID_USAGE_Y, ref yMaxVal);
            joystick.GetVJDAxisMin(deviceId, HID_USAGES.HID_USAGE_Y, ref yMinVal);
        }
コード例 #2
0
        public TesterForm()
        {
            InitializeComponent();
            joystick = new vJoy();
            position = new vJoy.JoystickState();


            /////	General driver data
            short iVer = joystick.GetvJoyVersion();
            bool enabled = joystick.vJoyEnabled();
            string Prd = joystick.GetvJoyProductString();
            string Mnf = joystick.GetvJoyManufacturerString();
            string Srl = joystick.GetvJoySerialNumberString();
            string prt = String.Format("Product: {0}; Version {1:X}; Manuf: {2}; Serial:{3}", Prd, iVer, Mnf, Srl);
            label1.Text = prt;
            Enbld.Checked = enabled;

            /////	vJoy Device properties
            int nBtn = joystick.GetVJDButtonNumber(id);
            int nDPov = joystick.GetVJDDiscPovNumber(id);
            int nCPov = joystick.GetVJDContPovNumber(id);
            bool X_Exist = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_X);
            bool Y_Exist = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_Y);
            bool Z_Exist = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_Z);
            bool RX_Exist = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_RX);
            prt = String.Format("Device[{0}]: Buttons={1}; DiscPOVs:{2}; ContPOVs:{3}", id, nBtn, nDPov, nCPov);
            label2.Text = prt;

            UInt32 DllVer = 0, DrvVer = 0;
            bool match = joystick.DriverMatch(ref DllVer, ref DrvVer);
            if (match)
                prt = String.Format("Version of Driver Matches DLL Version {0:X}", DllVer);
            else
                prt = String.Format("Version of Driver ({0:X}) does NOT match DLL Version ({1:X})", DrvVer, DllVer);
            label7.Text = prt;

            long max = 10, min = 10;
            bool ok;
            ok = joystick.GetVJDAxisMax(id, HID_USAGES.HID_USAGE_X, ref max);
            ok = joystick.GetVJDAxisMin(id, HID_USAGES.HID_USAGE_X, ref min);

            /////	Write access to vJoy Device - Basic
            VjdStat status;
            status = joystick.GetVJDStatus(id);
            bool acq = joystick.AcquireVJD(id);
            status = joystick.GetVJDStatus(id);

            position.AxisX = 1000;
            position.AxisY = 5000;
            position.AxisZ = 10000;
            position.AxisXRot = 20000;
            position.Buttons = 0xA5A5A5A5;
            position.ButtonsEx1 = 0;
            bool upd = joystick.UpdateVJD(id, ref position);
            status = joystick.GetVJDStatus(id);

            //// Reset functions
            joystick.ResetButtons(id);

            // Register callback function
            // Function to register:     Removal()
            // User data to pass:        label2
            joystick.RegisterRemovalCB(Removal, label2);
            
        }