Esempio n. 1
0
        // ctor
        public OptionTree(DeviceCls device)
        {
            m_tuning.Add("flight_move_pitch", new DeviceTuningParameter("flight_move_pitch", device));
            m_tuning.Add("flight_move_yaw", new DeviceTuningParameter("flight_move_yaw", device));
            m_tuning.Add("flight_move_roll", new DeviceTuningParameter("flight_move_roll", device));
            m_tuning.Add("flight_move_strafe_vertical", new DeviceTuningParameter("flight_move_strafe_vertical", device));
            m_tuning.Add("flight_move_strafe_lateral", new DeviceTuningParameter("flight_move_strafe_lateral", device));
            m_tuning.Add("flight_move_strafe_longitudinal", new DeviceTuningParameter("flight_move_strafe_longitudinal", device));

            m_tuning.Add("flight_throttle_abs", new DeviceTuningParameter("flight_throttle_abs", device));
            m_tuning.Add("flight_throttle_rel", new DeviceTuningParameter("flight_throttle_rel", device));

            m_tuning.Add("flight_aim_pitch", new DeviceTuningParameter("flight_aim_pitch", device));
            m_tuning.Add("flight_aim_yaw", new DeviceTuningParameter("flight_aim_yaw", device));

            m_tuning.Add("flight_view_pitch", new DeviceTuningParameter("flight_view_pitch", device));
            m_tuning.Add("flight_view_yaw", new DeviceTuningParameter("flight_view_yaw", device));

            m_tuning.Add("turret_aim_pitch", new DeviceTuningParameter("turret_aim_pitch", device));
            m_tuning.Add("turret_aim_yaw", new DeviceTuningParameter("turret_aim_yaw", device));

            // Gamepad specific
            if (Gamepad.GamepadCls.IsDeviceClass(device.DevClass))
            {
                m_tuning.Add("fps_view_pitch", new DeviceTuningParameter("fps_view_pitch", device));
                m_tuning.Add("fps_view_yaw", new DeviceTuningParameter("fps_view_yaw", device));

                m_tuning.Add("fps_move_lateral", new DeviceTuningParameter("fps_move_lateral", device));
                m_tuning.Add("fps_move_longitudinal", new DeviceTuningParameter("fps_move_longitudinal", device));

                m_tuning.Add("mgv_view_pitch", new DeviceTuningParameter("mgv_view_pitch", device));
                m_tuning.Add("mgv_view_yaw", new DeviceTuningParameter("mgv_view_yaw", device));
            }
        }
        /// <summary>
        /// cTor with content
        /// </summary>
        /// <param name="deviceName">The device name</param>
        /// <param name="cmdCtrl">The command e.g. x,y, rotz etc</param>
        /// <param name="dz">The deadzone value as string (empty string disables)</param>
        /// <param name="sa">The saturation value as string (empty string disables)</param>
        public DeviceOptionParameter(DeviceCls device, string cmdCtrl, string dz, string sa)
        {
            m_deviceClass  = device.DevClass;
            m_deviceName   = device.DevName;
            m_deviceGUID   = device.DevInstanceGUID;
            m_deviceNumber = device.DevInstance;

            m_doID    = Deviceoptions.DevOptionID(m_deviceClass, m_deviceName, cmdCtrl);
            m_cmdCtrl = cmdCtrl;

            m_deadzone        = "0.000";
            m_deadzoneEnabled = false;
            if (!string.IsNullOrEmpty(dz))
            {
                m_deadzone        = dz;
                m_deadzoneEnabled = true;
            }

            m_saturationSupported = false;
            m_saturation          = "1.000";
            m_saturationEnabled   = false;
            if (Devices.Joystick.JoystickCls.IsDeviceClass(m_deviceClass))
            {
                m_saturationSupported = true;
                if (!string.IsNullOrEmpty(sa))
                {
                    m_saturation        = sa;
                    m_saturationEnabled = true;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Update the dataset
        /// </summary>
        /// <param name="dsa">The dataset</param>
        /// <param name="actionID">The actionID to update from</param>
        public void UpdateDataSet(DS_ActionMaps dsa, string actionID)
        {
            foreach (ActionMapCls am in this)
            {
                DS_ActionMaps.T_ActionMapRow amr = dsa.T_ActionMap.NewT_ActionMapRow( );

                foreach (ActionCls ac in am)
                {
                    int ilIndex = 0;
                    while (ac.InputList.Count > ilIndex)
                    {
                        if (actionID == DS_ActionMap.ActionID(am.MapName, ac.Key, ac.InputList[ilIndex].NodeIndex))
                        {
                            DS_ActionMaps.T_ActionRow ar = dsa.T_Action.FindByID_Action(actionID);
                            ar.Usr_Binding  = ac.InputList[ilIndex].DevInput;
                            ar.Usr_Modifier = ac.InputList[ilIndex].ActivationMode.Name;
                            ar.Disabled     = DeviceCls.IsDisabledInput(ac.InputList[ilIndex].Input);
                            ar.AcceptChanges( );
                            return;
                        }
                        ilIndex++;
                    }
                } // each Action
            }     // each ActionMap
        }
 public void AssignDynamicItems(DeviceCls dev, DeviceOptionParameter devOptionRef, string nodeText)
 {
     // using the public property to ensure the complete processing of the assignment
     NodeText        = nodeText; // must be first - the content is used later for DeviceOptionRef assignment
     GameDevice      = dev;
     DeviceoptionRef = devOptionRef;
 }
Esempio n. 5
0
        /// <summary>
        /// Query the devices if the input is disabled
        /// </summary>
        /// <param name="input">The input command</param>
        /// <returns>True if disabled input</returns>
        static public bool IsDisabledInput(string input)
        {
            bool disabledInput = false;

            disabledInput = DeviceCls.IsDisabledInput(input); // generic
            if (disabledInput)
            {
                return(disabledInput);
            }

            disabledInput = JoystickCls.IsDisabledInput(input);
            if (disabledInput)
            {
                return(disabledInput);
            }
            disabledInput = GamepadCls.IsDisabledInput(input);
            if (disabledInput)
            {
                return(disabledInput);
            }
            disabledInput = KeyboardCls.IsDisabledInput(input);
            if (disabledInput)
            {
                return(disabledInput);
            }
            disabledInput = MouseCls.IsDisabledInput(input);
            if (disabledInput)
            {
                return(disabledInput);
            }
            // others..
            return(disabledInput);
        }
Esempio n. 6
0
        /// <summary>
        /// Try to derive the device class from the devInput string (mo1_, kb1_, xi1_, jsN_)
        /// </summary>
        /// <param name="devInput">The input command string dev_input format</param>
        /// <returns>A proper DeviceClass string</returns>
        static public string DeviceClassFromInput(string devInput)
        {
            string deviceClass = DeviceCls.DeviceClass;

            deviceClass = JoystickCls.DeviceClassFromInput(devInput);
            if (!DeviceCls.IsUndefined(deviceClass))
            {
                return(deviceClass);
            }
            deviceClass = GamepadCls.DeviceClassFromInput(devInput);
            if (!DeviceCls.IsUndefined(deviceClass))
            {
                return(deviceClass);
            }
            deviceClass = KeyboardCls.DeviceClassFromInput(devInput);
            if (!DeviceCls.IsUndefined(deviceClass))
            {
                return(deviceClass);
            }
            deviceClass = MouseCls.DeviceClassFromInput(devInput);
            if (!DeviceCls.IsUndefined(deviceClass))
            {
                return(deviceClass);
            }
            // others..
            return(deviceClass);
        }
Esempio n. 7
0
 /// <summary>
 /// Read an action from XML - do some sanity checks
 /// </summary>
 /// <param name="xml">the XML action fragment</param>
 /// <returns>True if an action was decoded</returns>
 public bool fromXML(XElement actionNode)
 {
     ActionName = (string)actionNode.Attribute("name"); // mandadory
     foreach (XElement bindingNode in actionNode.Nodes( ))
     {
         string binding = bindingNode.Name.ToString( );
         string input = "", actModeName = "", multi = "";
         input = (string)bindingNode.Attribute("input"); // mandadory
         if (string.IsNullOrEmpty(input))
         {
             input = "";
         }
         actModeName = (string)bindingNode.Attribute("ActivationMode");
         multi       = (string)bindingNode.Attribute("multiTap");
         string device = (string)bindingNode.Attribute("device");
         //process
         input = DeviceCls.fromXML(input); // move from external to internal blend
         if (!string.IsNullOrEmpty(device))
         {
             // AC1 style - need to reformat mouse and keyboard according to AC2 style now
             if (KeyboardCls.IsDeviceClass(device))
             {
                 input = KeyboardCls.FromAC1(input);
             }
             else if (MouseCls.IsDeviceClass(device))
             {
                 input = MouseCls.FromAC1(input);
             }
             else if (GamepadCls.IsDeviceClass(device))
             {
                 input = GamepadCls.FromAC1(input);
             }
         }
         Device = Act.DeviceClassFromInput(input);
         ActivationMode actMode = null;
         if (!string.IsNullOrEmpty(actModeName))
         {
             actMode = ActivationModes.Instance.ActivationModeByName(actModeName); // should be a valid ActivationMode for this action
         }
         else
         {
             actMode = new ActivationMode(ActivationMode.Default); // no specific name given, use default
             if (!string.IsNullOrEmpty(multi))
             {
                 actMode.MultiTap = int.Parse(multi); // modify with given multiTap
             }
         }
         if (binding == "rebind")
         {
             Key          = Act.DevTag(Device) + ActionName; // unique id of the action
             ActionDevice = Act.ADevice(Device);             // get the enum of the input device
         }
         AddCommand(input, actMode);
     }//foreach
     return(true);
 }
Esempio n. 8
0
        // ctor
        public OptionTree(DeviceCls device)
        {
            if (m_profileOptions.Count( ) == 0)
            {
                log.Error("cTor OptionTree - profile not yet read");
            }

            // get options for the device class
            var devOpts = m_profileOptions.Where(x => x.DeviceClass == device.DevClass);

            foreach (ProfileOptionRec rec in devOpts)
            {
                m_tuning.Add(rec.OptName, new DeviceTuningParameter(rec.OptName, device));
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Converts all maps into a DataSet
        /// </summary>
        /// <param name="dsa">The dataset to populate</param>
        public void ToDataSet(DS_ActionMaps dsa)
        {
            dsa.Clear( );
            if (dsa.HasChanges( ))
            {
                dsa.T_ActionMap.AcceptChanges( );
            }

            int AMcount = 1;

            foreach (ActionMapCls am in this)
            {
                DS_ActionMaps.T_ActionMapRow amr = dsa.T_ActionMap.NewT_ActionMapRow( );
                string amShown = DS_ActionMap.ActionMapShown(SCUiText.Instance.Text(am.MapName), AMcount++);

                amr.ID_ActionMap = amShown;
                dsa.T_ActionMap.AddT_ActionMapRow(amr);

                foreach (ActionCls ac in am)
                {
                    int ilIndex = 0;
                    while (ac.InputList.Count > ilIndex)
                    {
                        DS_ActionMaps.T_ActionRow ar = dsa.T_Action.NewT_ActionRow( );
                        ar.ID_Action     = DS_ActionMap.ActionID(am.MapName, ac.Key, ac.InputList[ilIndex].NodeIndex); // make a unique key
                        ar.AddBind       = (ilIndex > 0);                                                              // all but the first are addbinds
                        ar.REF_ActionMap = amShown;
                        ar.ActionName    = ac.ActionName;
                        ar.ActionText    = SCUiText.Instance.Text(ac.ActionName);
                        ar.Device        = ac.Device;
                        ar.Def_Binding   = ac.DefBinding;
                        ar.Def_Modifier  = ac.DefActivationMode.Name;
                        ar.Usr_Binding   = ac.InputList[ilIndex].DevInput;
                        ar.Usr_Modifier  = ac.InputList[ilIndex].ActivationMode.Name;
                        ar.Disabled      = DeviceCls.IsDisabledInput(ac.InputList[ilIndex].Input);
                        dsa.T_Action.AddT_ActionRow(ar);

                        ilIndex++;
                    }
                } // each Action
            }     // each ActionMap

            // finally
            if (dsa.HasChanges( ))
            {
                dsa.AcceptChanges( );
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Dump the action as partial XML nicely formatted
        /// </summary>
        /// <returns>the action as XML fragment</returns>
        public string toXML( )
        {
            string r = "";

            if (!string.IsNullOrEmpty(Input))
            {
                // regular - apply XML formatting to internally blended items
                r += string.Format("input=\"{0}_{1}\" {2} ", DevID, DeviceCls.toXML(Input), DeviceCls.toXMLBlendExtension(Input)); // add multitap override if needed
                if (!ActivationMode.Equals(ActivationMode.Default))
                {
                    r += string.Format("ActivationMode=\"{0}\" {1} ", ActivationMode.Name, MutitapFudge(ActivationMode));
                }
            }
            r += string.Format(" />\n");

            return(r);
        }
Esempio n. 11
0
        /// <summary>
        /// Disable the input for a specific device - input is a generic Disabled Input
        /// </summary>
        /// <param name="input">An input (generic disable or a valid command)</param>
        /// <param name="aDevice">A valid device</param>
        /// <returns>A device diabled or the original input if it was not a disabled</returns>
        static public string DisableInput(string input, ActionDevice aDevice)
        {
            if (DeviceCls.IsDisabledInput(input))
            {
                // was generic blind - return a device specific disabled input
                switch (aDevice)
                {
                case ActionDevice.AD_Gamepad: return(GamepadCls.DisabledInput);

                case ActionDevice.AD_Joystick: return(JoystickCls.DisabledInput);

                case ActionDevice.AD_Keyboard: return(KeyboardCls.DisabledInput);

                case ActionDevice.AD_Mouse: return(MouseCls.DisabledInput);

                default: return("");
                }
            }
            else
            {
                return(input); // not disabled - just return the input
            }
        }
Esempio n. 12
0
 public DeviceTuningParameter(string optName, DeviceCls device)
 {
     m_option   = optName;
     GameDevice = device;
 }