예제 #1
0
    public InputSetting(
        ControllerType _controllerType,
        ControllerElementType _elementType,
        int _elementIdentifierId,
        AxisRange _axisRange,
        KeyCode _keyboardKey,
        ModifierKeyFlags _modifierKeyFlags,
        int _actionId,
        Pole _axisContribution,
        bool _invert,
        int _elementMapId)
    {
        int num = 0;

        this.layoutId            = num;
        this.categoryId          = num;
        this.controllerType      = _controllerType;
        this.elementType         = _elementType;
        this.elementIdentifierId = _elementIdentifierId;
        this.axisRange           = _axisRange;
        this.keyboardKey         = _keyboardKey;
        this.modifierKeyFlags    = _modifierKeyFlags;
        this.actionId            = _actionId;
        this.axisContribution    = _axisContribution;
        this.invert       = _invert;
        this.elementMapId = _elementMapId;
    }
예제 #2
0
        private void PollKeyboardForAssignment()
        {
            int num = 0;
            ControllerPollingInfo pollingInfo      = default(ControllerPollingInfo);
            ControllerPollingInfo pollingInfo2     = default(ControllerPollingInfo);
            ModifierKeyFlags      modifierKeyFlags = ModifierKeyFlags.None;

            foreach (ControllerPollingInfo controllerPollingInfo in ReInput.controllers.Keyboard.PollForAllKeys())
            {
                KeyCode keyboardKey = controllerPollingInfo.keyboardKey;
                if (keyboardKey != KeyCode.AltGr)
                {
                    if (Keyboard.IsModifierKey(controllerPollingInfo.keyboardKey))
                    {
                        if (num == 0)
                        {
                            pollingInfo2 = controllerPollingInfo;
                        }
                        modifierKeyFlags |= Keyboard.KeyCodeToModifierKeyFlags(keyboardKey);
                        num++;
                    }
                    else if (pollingInfo.keyboardKey == KeyCode.None)
                    {
                        pollingInfo = controllerPollingInfo;
                    }
                }
            }
            if (pollingInfo.keyboardKey == KeyCode.None)
            {
                if (num > 0 && num == 1)
                {
                    if (ReInput.controllers.Keyboard.GetKeyTimePressed(pollingInfo2.keyboardKey) > 1f)
                    {
                        this._entry.pollingInfo    = pollingInfo2;
                        this._entry.controllerId   = 0;
                        this._entry.controllerType = ControllerType.Keyboard;
                        this._entry.controllerMap  = Input.player.controllers.maps.GetMap(ControllerType.Keyboard, 0, 0, 1);
                        this.CheckMappingConflictAndConfirm();
                        return;
                    }
                }
                return;
            }
            if (num == 0)
            {
                this._entry.pollingInfo    = pollingInfo;
                this._entry.controllerId   = 0;
                this._entry.controllerType = ControllerType.Keyboard;
                this._entry.controllerMap  = Input.player.controllers.maps.GetMap(ControllerType.Keyboard, 0, 0, 1);
                this.CheckMappingConflictAndConfirm();
                return;
            }
            this._entry.pollingInfo      = pollingInfo;
            this._entry.modifierKeyFlags = modifierKeyFlags;
            this._entry.controllerId     = 0;
            this._entry.controllerType   = ControllerType.Keyboard;
            this._entry.controllerMap    = Input.player.controllers.maps.GetMap(ControllerType.Keyboard, 0, 0, 1);
            this.CheckMappingConflictAndConfirm();
        }
예제 #3
0
 protected void UpdateStoreValue(ModifierKeyFlags newValue)
 {
     if (!newValue.Equals(storeValue.Value))   // value changed
     // Store new value
     {
         storeValue.Value = newValue;
     }
 }
예제 #4
0
    private ElementAssignment ToElementAssignment(
        ControllerPollingInfo _pollingInfo,
        ModifierKeyFlags _modifierKeyFlag,
        AxisRange _axisRange,
        int _actionId,
        ActionElementMap _actionElementMap)
    {
        AxisRange axisRange = (AxisRange)1;

        if (((ControllerPollingInfo) ref _pollingInfo).get_elementType() == null)
        {
            axisRange = _axisRange != null ? (((ControllerPollingInfo) ref _pollingInfo).get_axisPole() != null ? (AxisRange)2 : (AxisRange)1) : (AxisRange)0;
        }
        return(new ElementAssignment(((ControllerPollingInfo) ref _pollingInfo).get_controllerType(), ((ControllerPollingInfo) ref _pollingInfo).get_elementType(), ((ControllerPollingInfo) ref _pollingInfo).get_elementIdentifierId(), axisRange, ((ControllerPollingInfo) ref _pollingInfo).get_keyboardKey(), _modifierKeyFlag, _actionId, _axisRange != 2 ? (Pole)0 : (Pole)1, false, _actionElementMap == null ? -1 : _actionElementMap.get_id()));
    }
예제 #5
0
        public override string ModifierKeyFlagsToString(ModifierKeyFlags flags)
        {
            int    count = 0;
            string label = string.Empty;

            // TODO: Make this use the HardwareMap so languages can be supported

            if (Keyboard.ModifierKeyFlagsContain(flags, ModifierKey.Control))
            {
                label += _modifierKeys.control;
                count++;
            }

            if (Keyboard.ModifierKeyFlagsContain(flags, ModifierKey.Command))
            {
                if (count > 0 && !string.IsNullOrEmpty(_modifierKeys.separator))
                {
                    label += _modifierKeys.separator;
                }
                label += _modifierKeys.command;
                count++;
            }

            if (Keyboard.ModifierKeyFlagsContain(flags, ModifierKey.Alt))
            {
                if (count > 0 && !string.IsNullOrEmpty(_modifierKeys.separator))
                {
                    label += _modifierKeys.separator;
                }
                label += _modifierKeys.alt;
                count++;
            }
            if (count >= 3)
            {
                return(label);           // hit the limit of 3 modifiers
            }
            if (Keyboard.ModifierKeyFlagsContain(flags, ModifierKey.Shift))
            {
                if (count > 0 && !string.IsNullOrEmpty(_modifierKeys.separator))
                {
                    label += _modifierKeys.separator;
                }
                label += _modifierKeys.shift;
                count++;
            }

            return(label);
        }
예제 #6
0
 public override string GetElementIdentifierName(KeyCode keyCode, ModifierKeyFlags modifierKeyFlags)
 {
     if (modifierKeyFlags != ModifierKeyFlags.None)
     {
         return(string.Format(
                    "{0}{1}{2}",
                    ModifierKeyFlagsToString(modifierKeyFlags),
                    _modifierKeys.separator,
                    Keyboard.GetKeyName(keyCode)
                    ));
     }
     else
     {
         return(Keyboard.GetKeyName(keyCode));
     }
 }
예제 #7
0
 public ElementAssignment ToElementAssignment(ControllerPollingInfo pollingInfo, ModifierKeyFlags modifierKeyFlags)
 {
     this.pollingInfo      = pollingInfo;
     this.modifierKeyFlags = modifierKeyFlags;
     return(ToElementAssignment());
 }
예제 #8
0
 public abstract string ModifierKeyFlagsToString(ModifierKeyFlags flags);
예제 #9
0
 public abstract string GetElementIdentifierName(KeyCode keyCode, ModifierKeyFlags modifierKeyFlags);