Exemplo n.º 1
0
 public ControllerDefinition(ControllerDefinition source)
     : this()
 {
     Name = source.Name;
     BoolButtons.AddRange(source.BoolButtons);
     AxisControls.AddRange(source.AxisControls);
     AxisRanges.AddRange(source.AxisRanges);
     AxisConstraints.AddRange(source.AxisConstraints);
     CategoryLabels = source.CategoryLabels;
 }
Exemplo n.º 2
0
 void AxisCreationHelper(int controller_id, AxisControls control, int axisID)
 {
     AddAxis(new InputAxis()
     {
         name        = ammend(controller_id, control.ToString()),
         axis        = axisID,
         joyNum      = controller_id + 1, //reset to zero
         type        = AxisType.JoystickAxis,
         gravity     = 0,
         dead        = 0.19f,
         sensitivity = 1
     });
 }
Exemplo n.º 3
0
        private void RunRecieve()
        {
            IntPtr ptr = Marshal.AllocHGlobal(256);

            while (Connected)
            {
                // Debug.Log("recieving");
                try
                {
                    Marshal.Copy(ReadBytes(Marshal.SizeOf(typeof(Header))), 0, ptr, Marshal.SizeOf(typeof(Header)));
                    Header header = (Header)Marshal.PtrToStructure(ptr, typeof(Header));

                    if (header.type == 1)
                    {
                        Marshal.Copy(ReadBytes(Marshal.SizeOf(typeof(ControlPacket))), 0, ptr, Marshal.SizeOf(typeof(ControlPacket)));
                        ControlPacket cp = (ControlPacket)Marshal.PtrToStructure(ptr, typeof(ControlPacket));
                        if (cp.ID > lastCPID)
                        {
                            lastCPID = cp.ID;
                            VCList.Enqueue(CPToVC(cp));
                            axisControls = CPToAC(cp);
                        }
                    }
                    else if (header.type == 2)
                    {
                        Marshal.Copy(ReadBytes(Marshal.SizeOf(typeof(ManChangePacket))), 0, ptr, Marshal.SizeOf(typeof(ManChangePacket)));
                        ManChangePacket mcp = (ManChangePacket)Marshal.PtrToStructure(ptr, typeof(ManChangePacket));
                        MCPList.Enqueue(mcp);
                    }
                    else
                    {
                        Debug.Log("Incorrect header");
                    }
                }
                catch (IOException)
                {
                    Debug.Log("Error Recieving");
                    Connected = false;
                }
            }
            Marshal.FreeHGlobal(ptr);
        }
Exemplo n.º 4
0
 public bool Any()
 {
     return(BoolButtons.Any() || AxisControls.Any());
 }
Exemplo n.º 5
0
        public static void Callback(FlightCtrlState s)
        {
            if (Main.conn == null)
            {
                return;
            }
            AxisControls ac = Main.conn.GetAxisControls();

            switch (ac.ThrottleMode)
            {
            case 1:
                s.mainThrottle = ac.Throttle;
                break;

            case 2:
                if (s.mainThrottle == 0)
                {
                    s.mainThrottle = ac.Throttle;
                }
                break;

            case 3:
                if (ac.Throttle != 0)
                {
                    s.mainThrottle = ac.Throttle;
                }
                break;

            default:
                break;
            }

            if (Math.Abs(ac.Pitch) < ac.SASTol)
            {
                ac.Pitch = s.pitch;
            }
            if (Math.Abs(ac.Roll) < ac.SASTol)
            {
                ac.Roll = s.roll;
            }
            if (Math.Abs(ac.Yaw) < ac.SASTol)
            {
                ac.Yaw = s.yaw;
            }
            switch (ac.RotMode)
            {
            case 1:
                s.pitch = ac.Pitch;
                s.roll  = ac.Roll;
                s.yaw   = ac.Yaw;
                break;

            case 2:
                if (s.pitch == 0)
                {
                    s.pitch = ac.Pitch;
                }
                if (s.roll == 0)
                {
                    s.roll = ac.Roll;
                }
                if (s.yaw == 0)
                {
                    s.yaw = ac.Yaw;
                }
                break;

            case 3:
                if (ac.Pitch != 0)
                {
                    s.pitch = ac.Pitch;
                }
                if (ac.Roll != 0)
                {
                    s.roll = ac.Roll;
                }
                if (ac.Yaw != 0)
                {
                    s.yaw = ac.Yaw;
                }
                break;

            default:
                break;
            }

            switch (ac.TransMode)
            {
            case 1:
                s.X = ac.TX;
                s.Y = ac.TY;
                s.Z = ac.TZ;
                break;

            case 2:
                if (s.X == 0)
                {
                    s.X = ac.TX;
                }
                if (s.Y == 0)
                {
                    s.Y = ac.TY;
                }
                if (s.Z == 0)
                {
                    s.Z = ac.TZ;
                }
                break;

            case 3:
                if (ac.TX != 0)
                {
                    s.X = ac.TX;
                }
                if (ac.TY != 0)
                {
                    s.Y = ac.TY;
                }
                if (ac.TZ != 0)
                {
                    s.Z = ac.TZ;
                }
                break;

            default:
                break;
            }

            switch (ac.WheelMode)
            {
            case 1:
                s.wheelSteer    = ac.WheelSteer;
                s.wheelThrottle = ac.WheelThrottle;
                break;

            case 2:
                if (s.wheelSteer == 0)
                {
                    s.wheelSteer = ac.WheelSteer;
                }
                if (s.wheelThrottle == 0)
                {
                    s.wheelThrottle = ac.WheelThrottle;
                }
                break;

            case 3:
                if (ac.WheelSteer != 0)
                {
                    s.wheelSteer = ac.WheelSteer;
                }
                if (ac.WheelThrottle != 0)
                {
                    s.wheelThrottle = ac.WheelThrottle;
                }
                break;

            default:
                break;
            }
        }