Example #1
0
 public override void UpdateJoystick(VJoyBase vjoy)
 {
     if (Button >= 0)
     {
         vjoy.SetButton(Button, Output > 0);
     }
 }
Example #2
0
        public void Init(VJoyBase vjoy, int[] channels)
        {
            update = null;
            if (scriptSource == null)
            {
                return;
            }

            try {
                // setup proxies
                UserData.RegisterProxyType <MappingProxy, Mapping>(m => new MappingProxy(m));
                UserData.RegisterProxyType <VJoyProxy, VJoyBase>(vj => new VJoyProxy(vj));

                // setup globals
                script.Globals["AXIS_X"]   = 1;
                script.Globals["AXIS_Y"]   = 2;
                script.Globals["AXIS_Z"]   = 3;
                script.Globals["AXIS_RX"]  = 4;
                script.Globals["AXIS_RY"]  = 5;
                script.Globals["AXIS_RZ"]  = 6;
                script.Globals["AXIS_SL0"] = 7;
                script.Globals["AXIS_SL1"] = 8;

                script.Globals["VJoy"]    = vjoy;
                script.Globals["Channel"] = (Func <int, int>)(index => {
                    if (index < 1 || index > channels.Length)
                    {
                        throw new ScriptRuntimeException("Invalid Channel index");
                    }
                    return(channels[index - 1]);
                });
                script.Globals["Mapping"] = (Func <int, Mapping>)(index => {
                    var m = MainForm.Instance.MappingAt(index - 1);
                    if (m == null)
                    {
                        throw new ScriptRuntimeException("Invalid Mapping index");
                    }
                    return(m);
                });

                script.Globals["Failsafe"] = false;

                // execute code
                script.DoString(scriptSource, null, "Script");
                script.Options.DebugPrint = print;

                // save update function
                update = script.Globals.Get("update").Function;

                initted = true;
            }
            catch (InterpreterException ex) {
                throw ex;
            }
        }
        public override void UpdateJoystick(VJoyBase vjoy)
        {
            int v = (int)Output;

            for (var i = 0; i < 16; i++)
            {
                var p = Parameters[i];
                if (p.Enabled && p.Button >= 0)
                {
                    vjoy.SetButton(p.Button, ((v & (1 << i)) != 0));
                }
            }
        }
Example #4
0
        public void Update(VJoyBase vjoy, int[] channels, bool failsafe)
        {
            if (!initted)
            {
                Init(vjoy, channels);
            }

            if (update != null)
            {
                try {
                    script.Globals["Failsafe"] = failsafe;
                    update.Call();
                }
                catch (InterpreterException ex) {
                    update = null;
                    throw ex;
                }
            }
        }
Example #5
0
 /// <summary>
 /// This method gets called when the mapping should write its joystick.
 /// </summary>
 abstract public void UpdateJoystick(VJoyBase vjoy);
 public override void UpdateJoystick(VJoyBase vjoy)
 {
     vjoy.SetAxis(Axis, Output);
 }
Example #7
0
 internal VJoyProxy(VJoyBase vj)
 {
     vjoy = vj;
 }