Ejemplo n.º 1
0
        private vJoy initVjoy(uint id)
        {
            var joystick = new vJoy();
            var iReport  = new vJoy.JoystickState();

            // Get the state of the requested device
            VjdStat status = joystick.GetVJDStatus(id);

            /*switch (status)
             * {
             *  case VjdStat.VJD_STAT_OWN:
             *      MessageBox.Show(string.Format("vJoy Device {0} is already owned by this feeder\n", id));
             *      break;
             *  case VjdStat.VJD_STAT_FREE:
             *      MessageBox.Show(string.Format("vJoy Device {0} is free\n", id));
             *      break;
             *  case VjdStat.VJD_STAT_BUSY:
             *      MessageBox.Show(string.Format("vJoy Device {0} is already owned by another feeder\nCannot continue\n", id));
             *      return joystick;
             *  case VjdStat.VJD_STAT_MISS:
             *      MessageBox.Show(string.Format("vJoy Device {0} is not installed or disabled\nCannot continue\n", id));
             *      return joystick;
             *  default:
             *      MessageBox.Show(string.Format("vJoy Device {0} general error\nCannot continue\n", id));
             *      return joystick;
             * }*/
            bool AxisX = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_X);

            if (joystick.AcquireVJD(id) == false)
            {
                MessageBox.Show("Could not acquire vJoy " + id);
            }
            Console.WriteLine(AxisX);
            return(joystick);
        }
Ejemplo n.º 2
0
        public JoystickHelper()
        {
            keys     = new Keys();
            joystick = new vJoy();
            iReport  = new vJoy.JoystickState();
            long lAxisMax = 0;

            joystick.GetVJDAxisMax(id, HID_USAGES.HID_USAGE_X, ref lAxisMax);
            axisMax = (int)lAxisMax;

            string error = null;

            int nDevices = 0;

            for (uint i = 1; i <= 16; i++)
            {
                if ((error = vjoyhelper.setup(joystick, i)) != null)
                {
                    // Assume no more devices are set up correctly
                    break;
                }
                nDevices++;
            }
            for (int i = 1; i <= nDevices; i++)
            {
                availJoy.Add(i);
            }
            numberOfDevices = nDevices;
        }
Ejemplo n.º 3
0
        public vJoyFeeder()
        {
            NbButtons = -1;
            // Create one joystick object and a position structure.
            Joystick    = new vJoy();
            Report      = new vJoy.JoystickState();
            FFBReceiver = new vJoyFFBReceiver();

            // Prepare list of vJoy's axes configuration. This is done
            // only one time after retreiving vJoy's information

            // Fill all axes
            HIDAxesInfo.Clear();
            foreach (HID_USAGES toBeTested in Enum.GetValues(typeof(HID_USAGES)))
            {
                // Skip POV
                if (toBeTested == HID_USAGES.HID_USAGE_POV)
                {
                    continue;
                }
                var name     = toBeTested.ToString().Replace("HID_USAGE_", "");
                var axisinfo = new vJoyAxisInfos();
                axisinfo.HID_Usage = toBeTested;
                axisinfo.Name      = name;
                HIDAxesInfo.Add(axisinfo);
            }

            // Fill OnlyUsedInfo by copying reference from AllAxesInfo once done
            ConfiguredvJoyAxes.Clear();
        }
Ejemplo n.º 4
0
        protected int GetValue(ref vJoy.JoystickState joyReport, HID_USAGES hid)
        {
            switch (hid)
            {
            case HID_USAGES.HID_USAGE_X:
                return(joyReport.AxisX);

            case HID_USAGES.HID_USAGE_Y:
                return(joyReport.AxisY);

            case HID_USAGES.HID_USAGE_Z:
                return(joyReport.AxisZ);

            case HID_USAGES.HID_USAGE_RX:
                return(joyReport.AxisXRot);

            case HID_USAGES.HID_USAGE_RY:
                return(joyReport.AxisYRot);

            case HID_USAGES.HID_USAGE_RZ:
                return(joyReport.AxisZRot);

            case HID_USAGES.HID_USAGE_SL0:
                return(joyReport.Slider);

            case HID_USAGES.HID_USAGE_SL1:
                return(joyReport.Dial);

            default:
                return(0);
            }
        }
Ejemplo n.º 5
0
        private vJoy.JoystickState GetZeroJoystickInput()
        {
            vJoy.JoystickState jS = new vJoy.JoystickState();
            jS.Aileron    = 0;
            jS.AxisVBRX   = 0;
            jS.AxisVBRY   = 0;
            jS.AxisVBRZ   = 0;
            jS.AxisVX     = 0;
            jS.AxisVY     = 0;
            jS.AxisVZ     = 0;
            jS.AxisX      = 0;
            jS.AxisXRot   = 0;
            jS.AxisY      = 0;
            jS.AxisYRot   = 0;
            jS.AxisZ      = 0;
            jS.AxisZRot   = 0;
            jS.bDevice    = 0;
            jS.bHats      = 0;
            jS.bHatsEx1   = 0;
            jS.bHatsEx2   = 0;
            jS.bHatsEx3   = 0;
            jS.Buttons    = 0;
            jS.ButtonsEx1 = 0;
            jS.ButtonsEx2 = 0;
            jS.ButtonsEx3 = 0;
            jS.Dial       = 0;
            jS.Rudder     = 0;
            jS.Slider     = 0;
            jS.Throttle   = 0;
            jS.Wheel      = 0;

            return(jS);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Finds and updates a state of joystick identified and authorized by token.
 /// </summary>
 /// <param name="joyState">Struct with updated values of joystick axes, buttons, etc.</param>
 /// <param name="token">Authorizes the request</param>
 public void PostCurrentJoystickState(vJoy.JoystickState joyState, Guid token)
 {
     foreach (var joy in _joystics.Where(joy => joy.IsBusy && joy.Capabilities.Token == token))
     {
         joy.PostCurrentState(joyState);
         return;
     }
 }
Ejemplo n.º 7
0
 public void ApplyAll()
 {
     foreach (var state in _states.ToArray())
     {
         vJoy.JoystickState s = state.Value;
         _interface.UpdateVJD(state.Key, ref s);
     }
 }
Ejemplo n.º 8
0
 public void Apply(uint deviceId)
 {
     if (_states.ContainsKey(deviceId))
     {
         vJoy.JoystickState s = _states[deviceId];
         _interface.UpdateVJD(deviceId, ref s);
     }
 }
Ejemplo n.º 9
0
 public void SetJoystickInput(vJoy.JoystickState _iReport)
 {
     if (!_joystick.UpdateVJD(_id, ref _iReport))
     {
         _logger.WriteLog($"Feeding vJoy device number {_id} failed - try to enable device then press enter");
         Console.ReadKey(true);
         _joystick.AcquireVJD(_id);
     }
 }
Ejemplo n.º 10
0
        private void Initialize_vJoy()
        {
            // 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())
            {
                MessageBox.Show("vJoy driver not enabled: Failed Getting vJoy attributes.\n");
                Program._shouldExit = true;
                System.Environment.Exit(0);
            }

            // Get the state of the requested device
            VjdStat status = joystick.GetVJDStatus(id);

            switch (status)
            {
            case VjdStat.VJD_STAT_OWN:
                break;

            case VjdStat.VJD_STAT_FREE:
                break;

            case VjdStat.VJD_STAT_BUSY:
                MessageBox.Show("vJoy Device is already owned by another feeder\nInput feeding will not occur.");
                //System.Environment.Exit(0);
                return;

            case VjdStat.VJD_STAT_MISS:
                MessageBox.Show("vJoy Device is not installed or disabled\nInput feeding will not occur.");
                //System.Environment.Exit(0);
                return;

            default:
                MessageBox.Show("vJoy Device general error\nInput feeding will not occur.");
                //System.Environment.Exit(0);
                return;
            }
            ;

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

            // Acquire the target
            if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!joystick.AcquireVJD(id))))
            {
                MessageBox.Show("Failed to acquire vJoy device number");
                Program._shouldExit = true;
                System.Environment.Exit(0);
            }

            joystick.ResetVJD(id);
        }
Ejemplo n.º 11
0
    string Joystick(dynamic input)
    {
        id       = (uint)input.pid;
        joystick = new vJoy();
        iReport  = new vJoy.JoystickState();

        if (!joystick.vJoyEnabled())
        {
            return("vJoy driver not enabled: Failed Getting vJoy attributes.\n");
        }
        if (started == 0)
        {
            status = joystick.GetVJDStatus(id);
            switch (status)
            {
            case VjdStat.VJD_STAT_OWN:
            case VjdStat.VJD_STAT_FREE:
                break;

            case VjdStat.VJD_STAT_MISS:
            case VjdStat.VJD_STAT_BUSY:
            default:
                return("vJoy error\n" + status);
            }
            ;
            if (!joystick.AcquireVJD(id))
            {
                return("Cannot acquire!");
            }
            joystick.ResetVJD(id);
        }
        started = 1;
        bool   btnStatus = false;
        uint   btnId     = 0;
        string teste     = "";

        foreach (dynamic btn in input.buttons)
        {
            foreach (dynamic btnP in btn.Value)
            {
                if (btnP.Key == "bid")
                {
                    btnId = (uint)btnP.Value;
                }
                if (btnP.Key == "status")
                {
                    btnStatus = (bool)btnP.Value;
                }
            }
            joystick.SetBtn(btnStatus, id, btnId);
            teste += " " + btnId + ":(" + btnStatus + ")";
        }
        joystick.SetAxis(((int)input.axis.X), id, HID_USAGES.HID_USAGE_X);
        joystick.SetAxis(((int)input.axis.Y), id, HID_USAGES.HID_USAGE_Y);
        return("vJoy Enabled! " + id + teste);
    }
Ejemplo n.º 12
0
        public VJoyFeeder()
        {
            _joystick      = new vJoy();
            _joystickState = new vJoy.JoystickState();
            _id            = 1;
            _joystick.ResetVJD(_id);

            if (!_joystick.vJoyEnabled())
            {
                Console.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes.\n");
                return;
            }
            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(_id);

            switch (status)
            {
            case VjdStat.VJD_STAT_OWN:
                Console.WriteLine("vJoy Device {0} is already owned by this feeder\n", _id);
                break;

            case VjdStat.VJD_STAT_FREE:
                Console.WriteLine("vJoy Device {0} is free\n", _id);
                break;

            case VjdStat.VJD_STAT_BUSY:
                Console.WriteLine("vJoy Device {0} is already owned by another feeder\nCannot continue\n", _id);
                return;

            case VjdStat.VJD_STAT_MISS:
                Console.WriteLine("vJoy Device {0} is not installed or disabled\nCannot continue\n", _id);
                return;

            default:
                Console.WriteLine("vJoy Device {0} general error\nCannot continue\n", _id);
                return;
            }
            ;

            // 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);
            }

            _joystick.AcquireVJD(_id);
        }
Ejemplo n.º 13
0
        public vJoyFunctions(vJoy jostick)
        {
            _logger = new Logger();

            _joystick = jostick;
            IReportDescriptorProperties reportDescriptorProperties = new vJoyReportDescriptorProperties();

            _ffbHandler = new vJoyFfbHandler(_joystick, reportDescriptorProperties, _logger);
            _joystick.FfbRegisterGenCB(OnFfbArrival, _id);

            zeroJoystickState = GetZeroJoystickInput();
        }
Ejemplo n.º 14
0
        public MainWindowViewModel()
        {
            _client        = new ServiceClient();
            _joystickState = new vJoy.JoystickState();

            /* Before it we should check if service is available */
            if ((JoyCapabilities = _client.ConnectJoystick()).JoyId != 0)
            {
                JoyVM = new JoyVM();
                JoyVM.PropertyChanged += JoyVM_PropertyChanged;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Updates a state of joystick (values of buttons, axes, etc.) using a JoystickState struct
        /// </summary>
        /// <param name="joyState">Struct storing updated values of joystick state</param>
        public void PostCurrentState(vJoy.JoystickState joyState)
        {
            if (!IsBusy)
            {
                throw new Exception("You cannot change a state of a joystick which isn't connected.");
            }

            if (!_joystick.UpdateVJD(_joyId, ref joyState))
            {
                Disconnect();
            }
        }
Ejemplo n.º 16
0
        public override void Apply(ref vJoy.JoystickState state)
        {
            double axisX = 0;
            double axisY = 0;

            double maxValue = 0;

            switch (AType)
            {
            case AxisType.Stick:
                axisX    = GetValue(ref state, AxisX) - vJoyConstants.HALF_AXIS_VALUE - 0.5;
                axisY    = GetValue(ref state, AxisY) - vJoyConstants.HALF_AXIS_VALUE - 0.5;
                maxValue = vJoyConstants.HALF_AXIS_VALUE + 0.5;
                break;

            case AxisType.Trigger:
                axisX    = GetValue(ref state, AxisX);
                axisY    = GetValue(ref state, AxisY);
                maxValue = vJoyConstants.MAX_AXIS_VALUE;
                break;
            }

            double acturalDeadZone = maxValue * DeadZone;

            double mag = Math.Sqrt(axisX * axisX + axisY * axisY);

            if (mag < acturalDeadZone)
            {
                axisX = 0;
                axisY = 0;
            }
            else
            {
                double normX = axisX / mag; //0-1
                double normY = axisY / mag; //0-1
                axisX = normX * maxValue * ((mag - acturalDeadZone) / (maxValue - acturalDeadZone));
                axisY = normY * maxValue * ((mag - acturalDeadZone) / (maxValue - acturalDeadZone));
            }
            switch (AType)
            {
            case AxisType.Stick:
                axisX += vJoyConstants.HALF_AXIS_VALUE + 0.5;
                axisY += vJoyConstants.HALF_AXIS_VALUE + 0.5;
                break;

            case AxisType.Trigger:
                break;
            }

            SetValue(ref state, AxisX, (int)axisX);
            SetValue(ref state, AxisY, (int)axisY);
        }
Ejemplo n.º 17
0
        void _reset()
        {
            // reset state
            state = new vJoy.JoystickState();

            // center all axes
            foreach (var a in Enum.GetValues(typeof(Axes)))
            {
                SetAxis((int)a, 0.5);
            }

            SetState();
        }
Ejemplo n.º 18
0
        public vJoyFunctions(vJoy jostick, int id, ILogger customLogger)
        {
            _id     = (uint)id;
            _logger = customLogger != null ? customLogger : new Logger();

            _joystick = jostick;
            IReportDescriptorProperties reportDescriptorProperties = new vJoyReportDescriptorProperties();

            _ffbHandler = new vJoyFfbHandler(_joystick, reportDescriptorProperties, _logger);
            _joystick.FfbRegisterGenCB(OnFfbArrival, _id);

            zeroJoystickState = GetZeroJoystickInput();
        }
Ejemplo n.º 19
0
 public Launchpad()
 {
     joystick  = new vJoy();
     iReport   = new vJoy.JoystickState();
     padMatrix = new List <List <Pad> >();
     for (int i = 0; i < 8; i++)
     {
         padMatrix.Add(new List <Pad>());
         for (int j = 0; j < 9; j++)
         {
             padMatrix[i].Add(new Pad(Channel.Channel1));
         }
     }
 }
Ejemplo n.º 20
0
        public override void SetValue(ref vJoy.JoystickState state, float value)
        {
            var uintValue = _getValueDelegate(ref state);

            if (value != 0f)
            {
                uintValue |= _setBitMask;
            }
            else
            {
                uintValue &= _unsetBitMask;
            }

            _setValueDelegate(ref state, uintValue);
        }
Ejemplo n.º 21
0
        public override void Apply(ref vJoy.JoystickState state)
        {
            double axis     = 0;
            double maxValue = 0;

            switch (AType)
            {
            case AxisType.Stick:
                axis     = GetValue(ref state, Axis) - vJoyConstants.HALF_AXIS_VALUE - 0.5;
                maxValue = vJoyConstants.HALF_AXIS_VALUE + 0.5;
                break;

            case AxisType.Trigger:
                axis     = GetValue(ref state, Axis);
                maxValue = vJoyConstants.MAX_AXIS_VALUE;
                break;
            }

            double acturalDeadZone = maxValue * DeadZone;

            if (Math.Abs(axis) < acturalDeadZone)
            {
                axis = 0;
            }
            else
            {
                if (axis > 0)
                {
                    axis = maxValue * ((axis - acturalDeadZone) / (maxValue - acturalDeadZone));
                }
                else
                {
                    axis = maxValue * ((axis + acturalDeadZone) / (maxValue - acturalDeadZone));
                }
            }
            switch (AType)
            {
            case AxisType.Stick:
                axis += vJoyConstants.HALF_AXIS_VALUE + 0.5;
                break;

            case AxisType.Trigger:
                break;
            }
            SetValue(ref state, Axis, (int)axis);
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
0
 public vJoyFeeder()
 {
     // Create one joystick object and a position structure.
     Joystick    = new vJoy();
     Report      = new vJoy.JoystickState();
     FFBReceiver = new vJoyFFBReceiver();
     // vJoy has a maximum of 8 axes
     for (int i = 0; i < MAX_AXES_VJOY; i++)
     {
         var        axisinfo   = new vJoyAxisInfos();
         HID_USAGES toBeTested = (HID_USAGES)HID_USAGES.HID_USAGE_X + i;
         var        name       = toBeTested.ToString().Replace("HID_USAGE_", "");
         axisinfo.HID_Usage = toBeTested;
         axisinfo.Name      = name;
         axisinfo.ResetCorrectionFactors();
         AxesInfo.Add(axisinfo);
     }
 }
Ejemplo n.º 24
0
 public static void SetButton(this vJoy.JoystickState jostickState, int buttonNumber)
 {
     if (buttonNumber < 33)
     {
         jostickState.Buttons |= (uint)(1 << buttonNumber);
     }
     else if (buttonNumber < 65)
     {
         jostickState.bHatsEx1 |= (uint)(1 << (buttonNumber % 33 + 1));
     }
     else if (buttonNumber < 97)
     {
         jostickState.bHatsEx2 |= (uint)(1 << (buttonNumber % 65 + 1));
     }
     else if (buttonNumber < 129)
     {
         jostickState.bHatsEx3 |= (uint)(1 << (buttonNumber % 97 + 1));
     }
 }
Ejemplo n.º 25
0
        public vJoyHelper(USBHelper usb)
        {
            _joystick = new vJoy();
            bool tmp = _joystick.vJoyEnabled();

            _jState = new vJoy.JoystickState();
            _joystick.AcquireVJD(1);
            _joystick.ResetVJD(1);
            _maxVal  = 0;
            _axisAry = new Dictionary <HID_USAGES, bool>();
            foreach (HID_USAGES hidUsage in Enum.GetValues(typeof(HID_USAGES)))
            {
                _axisAry.Add(hidUsage, _joystick.GetVJDAxisExist(1, hidUsage));
            }

            _joystick.GetVJDAxisMax(1, HID_USAGES.HID_USAGE_X, ref _maxVal);
            _usb        = usb;
            usb.Polled += new EventHandler(OnUSBPolled);
        }
Ejemplo n.º 26
0
        public void ProcessEvents(IEnumerable <ControlEvent> events)
        {
            var state = _state;

            foreach (var @event in events)
            {
                if (@event.ControlId.ControllerId.Name != ControllerId.Name)
                {
                    continue;
                }

                var control = _controlSet.GetControlByName(@event.ControlId.Name);
                if (control != null)
                {
                    control.SetValue(ref state, @event.Value);
                }
            }

            _state = state;
        }
Ejemplo n.º 27
0
        void Start()
        {
            joystick = new vJoy();
            iReport  = new vJoy.JoystickState();

            if (joystick.vJoyEnabled())
            {
                VjdStat status        = joystick.GetVJDStatus(1);
                bool    AxisX         = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_X);
                int     nButtons      = joystick.GetVJDButtonNumber(id);
                int     ContPovNumber = joystick.GetVJDContPovNumber(id);
                int     DiscPovNumber = joystick.GetVJDDiscPovNumber(id);
                joystick.AcquireVJD(id);
                joystick.ResetVJD(id);
            }

            fpsMonitor = GetComponent <FpsMonitor> ();

            displayFacePointsToggle.isOn   = displayFacePoints;
            displayAxesToggle.isOn         = displayAxes;
            displayHeadToggle.isOn         = displayHead;
            displayEffectsToggle.isOn      = displayEffects;
            enableLowPassFilterToggle.isOn = enableLowPassFilter;

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();


            dlibShapePredictorFileName = DlibFaceLandmarkDetectorExample.dlibShapePredictorFileName;
            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = DlibFaceLandmarkDetector.UnityUtils.Utils.getFilePathAsync(dlibShapePredictorFileName, (result) => {
                getFilePath_Coroutine = null;

                dlibShapePredictorFilePath = result;
                Run();
            });
            StartCoroutine(getFilePath_Coroutine);
            #else
            dlibShapePredictorFilePath = DlibFaceLandmarkDetector.UnityUtils.Utils.getFilePath(dlibShapePredictorFileName);
            Run();
            #endif
        }
Ejemplo n.º 28
0
        public VJoyPlugin()
        {
            _controlSet     = new VJoyControlSet(ControllerId);
            _controllerInfo = new ControllerInfo(ControllerId.Name, 1, "vJoy joystick", _controlSet.Controls.Select(c => c.ControlInfo));

            _joystick = new vJoy();

            var state = new vJoy.JoystickState
            {
                bDevice = 1
            };

            foreach (var control in _controlSet.Controls)
            {
                control.SetValue(ref state, 0);
            }

            _state = state;

            _task = Task.Factory.StartNew(Poll, TaskCreationOptions.LongRunning);
        }
Ejemplo n.º 29
0
        public vJoyFeeder()
        {
            // Create one joystick object and a position structure.
            Joystick    = new vJoy();
            Report      = new vJoy.JoystickState();
            FFBReceiver = new vJoyFFBReceiver();

            AxesInfo = new List <vJoyAxisInfos>(MAX_AXES_VJOY);
            foreach (HID_USAGES toBeTested in Enum.GetValues(typeof(HID_USAGES)))
            {
                // Skip POV
                if (toBeTested == HID_USAGES.HID_USAGE_POV)
                {
                    continue;
                }
                var name     = toBeTested.ToString().Replace("HID_USAGE_", "");
                var axisinfo = new vJoyAxisInfos();
                axisinfo.HID_Usage = toBeTested;
                axisinfo.Name      = name;
                axisinfo.ResetCorrectionFactors();
                AxesInfo.Add(axisinfo);
            }
        }
Ejemplo n.º 30
0
        protected void SetValue(ref vJoy.JoystickState joyReport, HID_USAGES hid, int value)
        {
            switch (hid)
            {
            case HID_USAGES.HID_USAGE_X:
                joyReport.AxisX = value;
                break;

            case HID_USAGES.HID_USAGE_Y:
                joyReport.AxisY = value;
                break;

            case HID_USAGES.HID_USAGE_Z:
                joyReport.AxisZ = value;
                break;

            case HID_USAGES.HID_USAGE_RX:
                joyReport.AxisXRot = value;
                break;

            case HID_USAGES.HID_USAGE_RY:
                joyReport.AxisYRot = value;
                break;

            case HID_USAGES.HID_USAGE_RZ:
                joyReport.AxisZRot = value;
                break;

            case HID_USAGES.HID_USAGE_SL0:
                joyReport.Slider = value;
                break;

            case HID_USAGES.HID_USAGE_SL1:
                joyReport.Dial = value;
                break;
            }
        }