Beispiel #1
0
        public abstract void Destroy();         // called by AssignSwitches to remove old one

        #endregion

        #region Global indexed list
        /// <summary>Must be called once before using other methods.  Further calls ignored</summary>
        static public void Initialise()
        {
            if (g_Switches != null)
            {
                return;
            }
            // faster(?) than using Shared Sub?.  Should be called on app startup
            g_Switches          = new List <PhysicalSwitch>();
            m_EventForm         = new EventForm();
            m_EventForm.Visible = true;
            KeySwitch.Initialise();
            JoySwitch.Initialise();
            // PointerSwitch doesn't require anything
        }
Beispiel #2
0
        /// <summary>this is the ONLY correct public way of creating any switch</summary>
        public static void AssignSwitch(int index, Types type, int param)
        {
            if (g_Switches == null)
            {
                throw new InvalidOperationException("Initialise not called on Physical switch");
            }
            if (index < 0 || index > 7)
            {
                throw (new ArgumentException("Switch index should be 0-7"));                 // could be increased, this is just arbitrary sanity limit
            }
            while (g_Switches.Count <= index)
            {
                g_Switches.Add(null);
            }
            if (g_Switches[index] != null)
            {
                if (g_SelectedSwitch == g_Switches[index])
                {
                    g_SelectedSwitch = null;
                }
                g_Switches[index].Destroy();
                g_Switches[index] = null;
            }
            PhysicalSwitch create = null;

            switch (type)
            {
            case Types.Null:                     // leave as nothing
                break;

            case Types.Joystick:
                create = (PhysicalSwitch)JoySwitch.CreateSwitch(param);
                break;

            case Types.Keyboard:
                create = KeySwitch.CreateSwitch((Keys)param);
                break;

            case Types.Pointer:
                create = PointerSwitch.Create(param);
                break;

            default:
                throw new ArgumentException("Invalid switch type: " + type);
            }
            g_Switches[index] = create;
        }
Beispiel #3
0
        public static string GetParamDescription(Types type, int param)
        {
            // get description for Param for any type
            switch (type)
            {
            case Types.Null: return("--");

            case Types.Joystick: return(JoySwitch.GetParamDescription(param));

            case Types.Keyboard: return(KeySwitch.GetParamDescription(param));

            case Types.Pointer: return("");

            default:
                OnError("Unexpected type in GetParamDescription");
                return("?");
            }
        }