Ejemplo n.º 1
0
 /// <summary>
 /// Constructor for keyboard buttons.
 /// </summary>
 /// <param name="code"></param>
 /// <param name="onPress"></param>
 public ButtonTrigger(KeyCodes code, bool onPress)
 {
     this.deviceId          = 0;
     this.deviceType        = InputDeviceType.Keyboard;
     this.buttonId          = (uint)code;
     this.whenButtonPressed = onPress;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor for mouse buttons.
 /// </summary>
 /// <param name="button"></param>
 /// <param name="onPress"></param>
 public ButtonTrigger(uint button, bool onPress)
 {
     this.deviceId          = 0;
     this.deviceType        = InputDeviceType.Mouse;
     this.buttonId          = button;
     this.whenButtonPressed = onPress;
 }
    public void Refresh()
    {
        valid = false;
        if (IsMobile())
        {
            type  = InputDeviceType.MOBILE;
            valid = true;
        }
        else if (IsKeyboard())
        {
            type  = InputDeviceType.KEYBOARD;
            valid = true;
        }
        else if (IsController())
        {
            string[] joystickNames   = Input.GetJoystickNames();
            int      controllerIndex = CONTROLLERS.IndexOf(Id);

            if (controllerIndex < joystickNames.Length)
            {
                name = joystickNames[controllerIndex];

                if (name != "")
                {
                    valid = true;
                }
            }

            type = InputDeviceType.XBOX;
        }
    }
Ejemplo n.º 4
0
    // Token: 0x06000538 RID: 1336 RVA: 0x00048CDC File Offset: 0x000470DC
    private void Update()
    {
        this.MouseDelta    = Input.mousePosition - this.MousePrevious;
        this.MousePrevious = Input.mousePosition;
        InputDeviceType type = this.Type;

        if (Input.anyKey || Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2) || this.MouseDelta != Vector3.zero)
        {
            this.Type = InputDeviceType.MouseAndKeyboard;
        }
        if (Input.GetKey(KeyCode.Joystick1Button0) || Input.GetKey(KeyCode.Joystick1Button1) || Input.GetKey(KeyCode.Joystick1Button2) || Input.GetKey(KeyCode.Joystick1Button3) || Input.GetKey(KeyCode.Joystick1Button4) || Input.GetKey(KeyCode.Joystick1Button5) || Input.GetKey(KeyCode.Joystick1Button6) || Input.GetKey(KeyCode.Joystick1Button7) || Input.GetKey(KeyCode.Joystick1Button8) || Input.GetKey(KeyCode.Joystick1Button9) || Input.GetKey(KeyCode.Joystick1Button10) || Input.GetKey(KeyCode.Joystick1Button11) || Input.GetKey(KeyCode.Joystick1Button12) || Input.GetKey(KeyCode.Joystick1Button13) || Input.GetKey(KeyCode.Joystick1Button14) || Input.GetKey(KeyCode.Joystick1Button15) || Input.GetKey(KeyCode.Joystick1Button16) || Input.GetKey(KeyCode.Joystick1Button17) || Input.GetKey(KeyCode.Joystick1Button18) || Input.GetKey(KeyCode.Joystick1Button19) || Input.GetAxis("DpadX") > 0.5f || Input.GetAxis("DpadX") < -0.5f || Input.GetAxis("DpadY") > 0.5f || Input.GetAxis("DpadY") < -0.5f)
        {
            this.Type = InputDeviceType.Gamepad;
        }
        if (!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D) && (Input.GetAxis("Vertical") == 1f || Input.GetAxis("Vertical") == -1f || Input.GetAxis("Horizontal") == 1f || Input.GetAxis("Horizontal") == -1f))
        {
            this.Type = InputDeviceType.Gamepad;
        }
        if (this.Type != type)
        {
            PromptSwapScript[] array = Resources.FindObjectsOfTypeAll <PromptSwapScript>();
            foreach (PromptSwapScript promptSwapScript in array)
            {
                promptSwapScript.UpdateSpriteType(this.Type);
            }
        }
        this.Horizontal = Input.GetAxis("Horizontal");
        this.Vertical   = Input.GetAxis("Vertical");
    }
Ejemplo n.º 5
0
            public InputEvent inputEvent;       // DeviceID, key, velocity

            public ListViewItem入力リスト用(InputDeviceType deviceType, InputEvent inputEvent)
            {
                this.割り当て可能     = true;
                this.deviceType = deviceType;
                this.inputEvent = inputEvent;

                switch (deviceType)
                {
                case InputDeviceType.Keyboard:
                    this.Text = $"Keyboard, {inputEvent.Key}, '{(Keys)inputEvent.Key}'";
                    break;

                case InputDeviceType.GameController:
                    this.Text = $"GamePad, 0x{inputEvent.Key:X8}, '{HID.GetUsageName( (uint)inputEvent.Key )}'";
                    break;

                case InputDeviceType.MidiIn:
                    if (inputEvent.押された)
                    {
                        if (255 != inputEvent.Key)
                        {
                            this.Text =
                                $"MidiIn[{inputEvent.DeviceID}], " +
                                $"{inputEvent.Extra}, " +
                                $"{Properties.Resources.TXT_ノートオン}, " +
                                $"Note={inputEvent.Key}, " +
                                $"Velocity={inputEvent.Velocity}";
                            this.割り当て可能    = true;                        // 割り当て可
                            this.ForeColor = System.Drawing.Color.Black;  // 黒
                        }
                        else
                        {
                            // フットペダル
                            this.Text =
                                $"MidiIn[{inputEvent.DeviceID}], " +
                                $"{inputEvent.Extra}, " +
                                $"{Properties.Resources.TXT_コントロールチェンジ}, " +
                                $"Control={inputEvent.Control}(0x{inputEvent.Control:X2}), " +
                                $"Value={inputEvent.Velocity}";
                            this.割り当て可能    = false;                       // 割り当て不可
                            this.ForeColor = System.Drawing.Color.Green;  // 緑
                        }
                    }
                    else if (inputEvent.離された)
                    {
                        this.Text =
                            $"MidiIn[{inputEvent.DeviceID}], " +
                            $"{inputEvent.Extra}, " +
                            $"{Properties.Resources.TXT_ノートオフ}, " +
                            $"Note={inputEvent.Key}, " +
                            $"Velocity={inputEvent.Velocity}";
                        this.割り当て可能    = false;                           // 割り当て不可
                        this.ForeColor = System.Drawing.Color.Gray;       // 灰
                    }
                    break;

                default:
                    throw new ArgumentException("未対応のデバイスです。");
                }
            }
Ejemplo n.º 6
0
 ///API-No.55
 /// <summary>
 /// 关闭某个输入设备,支持的输入设备见InputDeviceType
 /// </summary>
 /// <param name="inputDevice">输入设备</param>
 public static void DisableInputDeivce(InputDeviceType inputDevice)
 {
     if (InputSystem.Instant)
     {
         InputSystem.Instant.UnRegisterInputDevice(inputDevice);
     }
 }
Ejemplo n.º 7
0
 ///API-No.55
 /// <summary>
 /// 关闭某个输入设备,支持的输入设备见InputDeviceType
 /// </summary>
 /// <param name="inputDevice">输入设备</param>
 public static void DisableInputDevice(InputDeviceType inputDevice)
 {
     if (Module_InputSystem.instance)
     {
         Module_InputSystem.instance.SetActiveInputDevice(inputDevice, false);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Determines what type of device triggered a WM_INPUT message (Used in the ProcessInputCommand method)
        /// </summary>
        /// <param name="param">The LParam from a WM_INPUT message</param>
        /// <returns>A DeviceType enum value</returns>
        private InputDeviceType GetDevice(int param)
        {
            InputDeviceType deviceType = InputDeviceType.Key;

            try
            {
                switch ((int)(((ushort)(param >> 16)) & FAPPCOMMAND_MASK))
                {
                case FAPPCOMMAND_OEM:
                    deviceType = InputDeviceType.OEM;
                    break;

                case FAPPCOMMAND_MOUSE:
                    deviceType = InputDeviceType.Mouse;
                    break;

                default:
                    deviceType = InputDeviceType.Key;
                    break;
                }
            }
            catch (Exception)
            {
            }

            return(deviceType);
        }
Ejemplo n.º 9
0
        public static DS4Device CreateDevice(InputDeviceType tempType,
                                             HidDevice hidDevice, string disName, VidPidFeatureSet featureSet = VidPidFeatureSet.DefaultDS4)
        {
            DS4Device temp = null;

            switch (tempType)
            {
            case InputDeviceType.DS4:
                temp = new DS4Device(hidDevice, disName, featureSet);
                break;

            case InputDeviceType.SwitchPro:
                temp = new SwitchProDevice(hidDevice, disName, featureSet);
                break;

            case InputDeviceType.JoyConL:
            case InputDeviceType.JoyConR:
                temp = new JoyConDevice(hidDevice, disName, featureSet);
                break;

            case InputDeviceType.DualSense:
                temp = new DualSenseDevice(hidDevice, disName, featureSet);
                break;
            }

            return(temp);
        }
 internal RawInputHeader(InputDeviceType deviceType, int structSize, IntPtr device, IntPtr param)
 {
     DeviceType   = deviceType;
     Size         = structSize;
     DeviceHandle = device;
     WParameter   = param;
 }
Ejemplo n.º 11
0
        //Inputs Parser
        public void InputsParse(string line)
        {
            string          id      = GetRegEx("id").Match(line).Value;
            string          address = GetRegAddr("addr").Match(line).Value;
            string          _type   = GetRegEx("type").Match(line).Value;
            InputDeviceType type    = (InputDeviceType)Enum.Parse(typeof(InputDeviceType), _type, true);

            if (type == InputDeviceType.tracker)
            {
                string loc   = GetRegComplex("loc").Match(line).Value;
                string locX  = GetRegProp("X").Match(loc).Value;
                string locY  = GetRegProp("Y").Match(loc).Value;
                string locZ  = GetRegProp("Z").Match(loc).Value;
                string rot   = GetRegComplex("rot").Match(line).Value;
                string rotP  = GetRegProp("P").Match(rot).Value;
                string rotY  = GetRegProp("Y").Match(rot).Value;
                string rotR  = GetRegProp("R").Match(rot).Value;
                string front = GetRegEx("front").Match(line).Value;
                string right = GetRegEx("right").Match(line).Value;
                string up    = GetRegEx("up").Match(line).Value;
                inputs.Add(new TrackerInput(id, address, locX, locY, locZ, rotP, rotY, rotR, front, right, up));
            }
            else
            {
                inputs.Add(new BaseInput(id, type, address));
            }
        }
Ejemplo n.º 12
0
 private void addInput(string type)
 {
     if (type != null)
     {
         if (type == "tracker")
         {
             currentConfig.inputs.Add(new TrackerInput {
                 id = "TrackerInputId", address = "[email protected]", locationX = "0", locationY = "0", locationZ = "0", rotationP = "0", rotationR = "0", rotationY = "0", front = "X", right = "Y", up = "-Z"
             });
         }
         else
         {
             InputDeviceType currentType = (InputDeviceType)System.Enum.Parse(typeof(InputDeviceType), type);
             currentConfig.inputs.Add(new BaseInput {
                 id = "InputId", type = currentType, address = "[email protected]"
             });
         }
         currentConfig.selectedInput = currentConfig.inputs.LastOrDefault();
         RefreshUiControls();
         //inputsListBox.Items.Refresh();
         try
         {
             ((CollectionViewSource)this.Resources["cvsInputTrackers"]).View.Refresh();
         }
         catch (NullReferenceException)
         {
         }
     }
 }
Ejemplo n.º 13
0
        private void fireInputEnd(InputDeviceType inputType, GamePadState gpdState, KeyboardState keyState, MouseState mosState, Keys keyBtn, GamepadCode gpdBtn, MouseCode mosBtn)
        {
            InputObject input = new InputObject(inputType, gpdState, mosState, keyBtn, gpdBtn, mosBtn);

            //General
            for (int i = 0; i < generalListeners.Count; i++)
            {
                GeneralInputListener listener = generalListeners[i];
                listener.InputEnded(input);
                switch (inputType)
                {
                case (InputDeviceType.Gamepad):
                    listener.GamepadInputEnded(input);
                    break;

                case (InputDeviceType.Keyboard):
                    listener.KeyboardInputEnded(input);
                    break;

                case (InputDeviceType.Mouse):
                    listener.MouseInputEnded(input);
                    break;
                }
            }
            //Others
            switch (inputType)
            {
            case (InputDeviceType.Gamepad):
                for (int i = 0; i < gamepadListeners.Count; i++)
                {
                    GamepadListener listener = gamepadListeners[i];
                    listener.InputEnded(input);
                }
                break;

            case (InputDeviceType.Keyboard):
                for (int i = 0; i < keyboardListeners.Count; i++)
                {
                    KeyboardListener listener = keyboardListeners[i];
                    listener.InputEnded(input);
                }
                if (keyboardBinds.ContainsKey(keyBtn))
                {
                    keyboardBinds[keyBtn].Ended();
                }
                break;

            case (InputDeviceType.Mouse):
                for (int i = 0; i < mouseListeners.Count; i++)
                {
                    MouseListener listener = mouseListeners[i];
                    listener.InputEnded(input);
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 14
0
            /// <summary>
            /// Reads the action from a stream.
            /// </summary>
            public override void Load(BinaryReader reader)
            {
                InputDeviceType = (InputDeviceType)reader.Read();
                var inputObject = new InputObject();

                inputObject.Load(reader);
                InputObject = inputObject;
            }
Ejemplo n.º 15
0
 private void OnInputUserChanged(InputUser arg1, InputUserChange arg2, InputDevice arg3)
 {
     if (arg2 == InputUserChange.ControlsChanged)
     {
         CurrentInputDevice = arg1.controlScheme.Value.name == "Gamepad" ? InputDeviceType.GAMEPAD : InputDeviceType.KEYBOARD;
         OnInputDeviceChanged?.Invoke(obj: CurrentInputDevice);
     }
 }
Ejemplo n.º 16
0
 public static bool InputDeviceStatus(InputDeviceType deviceType)
 {
     if (Module_InputSystem.instance)
     {
         return(Module_InputSystem.instance.GetInputDeviceStatus(deviceType));
     }
     return(false);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Generic button trigger.
 /// </summary>
 /// <param name="deviceType"></param>
 /// <param name="deviceId"></param>
 /// <param name="button"></param>
 /// <param name="onPress"></param>
 public ButtonTrigger(InputDeviceType deviceType, uint deviceId,
                      uint button, bool onPress)
 {
     this.deviceType        = deviceType;
     this.deviceId          = deviceId;
     this.buttonId          = button;
     this.whenButtonPressed = onPress;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// This is the constructor for DirectInput devices. See class description for information
        /// about this class.
        /// </summary>
        /// <param name="deviceType">The type of the device (DirectInput)</param>
        /// <param name="dInputController">The directInput controller instance.</param>
        public Remapper(InputDeviceType deviceType, DInputController dInputController)
        {
            DeviceType = deviceType;
            Controller = dInputController;

            // Retrieve the configuration location.
            GetConfigLocation(dInputController);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// The Remapper class provides the means of loading and saving individual configurations for
        /// each DirectInput and XInput Device in question.
        /// Separate implementations are provided for both DirectInput and XInput.
        /// </summary>
        /// <param name="deviceType">The type of the device (XInput)</param>
        /// <param name="xInputController">The directInput controller instance.</param>
        public Remapper(InputDeviceType deviceType, XInputController xInputController)
        {
            DeviceType = deviceType;
            Controller = xInputController;
            XInputPort = xInputController.ControllerId;

            // Retrieve the configuration location.
            GetConfigLocation(null);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public InputDeviceDescriptor(InputDeviceType type, string name,
                              uint deviceId, uint buttonCount, uint axisCount)
 {
     this.DeviceType  = type;
     this.Name        = name;
     this.DeviceId    = deviceId;
     this.ButtonCount = buttonCount;
     this.AxisCount   = axisCount;
 }
Ejemplo n.º 21
0
        public DeviceInput(InputDeviceType type)
        {
            inputType = type;

            //if (inputType==InputDeviceType.Virtual){
            //	virtualAxisValue = 0f;
            //virtualInputState = ButtonAction.NOTHING;
            //}
        }
Ejemplo n.º 22
0
        public InputObject(InputDeviceType deviceType, GamePadState gpdState, MouseState mosState, Keys keyBtn, GamepadCode gpdBtn, MouseCode musBtn)
        {
            this.gamepadCode  = gpdBtn;
            this.keyboardCode = keyBtn;
            this.mouseCode    = musBtn;

            this.gpdState = gpdState;
            this.mosState = mosState;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonRawInputDeviceInfo"/> class.
        /// </summary>
        /// <param name="name">The device name.</param>
        /// <param name="deviceType">The type of device.</param>
        /// <param name="className">Class name of the device.</param>
        /// <param name="hidPath">Human interface device path.</param>
        /// <param name="handle">Handle to the device.</param>
        /// <exception cref="System.ArgumentException">The handle is set to 0.</exception>
        /// <exception cref="System.ArgumentNullException">Either the name, className or hidPath are NULL or empty.</exception>
        public GorgonRawInputDeviceInfo(string name, InputDeviceType deviceType, string className, string hidPath, IntPtr handle)
            : base(name, deviceType, className, hidPath)
        {
            Handle = handle;

            // Get the usage information for the device.
            RID_DEVICE_INFO deviceInfo = Win32API.GetDeviceInfo(handle);

            Usage     = (HIDUsage)deviceInfo.hid.usUsage;
            UsagePage = (HIDUsagePage)deviceInfo.hid.usUsagePage;
        }
Ejemplo n.º 24
0
 public T GetInputDevice <T>(InputDeviceType type) where T : InputDeviceBase
 {
     foreach (var inputDevice in inputDeviceSupportList)
     {
         if (type == inputDevice.inputDeviceType)
         {
             return((T)inputDevice);
         }
     }
     return(null);
 }
Ejemplo n.º 25
0
 public bool GetInputDeviceStatus(InputDeviceType type)
 {
     _inputDevice = GetInputDevice <InputDeviceBase>(type);
     if (_inputDevice)
     {
         foreach (var part in _inputDevice.inputDevicePartList)
         {
             if (part.inputDataBase.isVaild == true)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 26
0
        public void AddControlInput(int controlIndex, string deviceName)
        {
            if (rebinding)
            {
                return;
            }
            //Debug.Log("Add new input for : " + controls[controlIndex].name + " of " + deviceName);

            InputDeviceType t = InputDeviceType.Keyboard;

            if (deviceName != "KeyboardMouse")
            {
                t = InputDeviceType.GamepadButton;
            }
            DeviceInput newInput = new DeviceInput(t);

            newInput.isCustom          = true;
            newInput.deviceName        = deviceName;
            newInput.commonMappingType = CommonGamepadInputs.NOBUTTON;            //don't remove this input when gamepads are unplugged/replugged

            if (t == InputDeviceType.Keyboard)
            {
                newInput.keyboardKeyCode = KeyCode.None;
            }

            if (t == InputDeviceType.GamepadButton)
            {
                newInput.gamepadButtonNumber = 18;
                newInput.displayName         = "B?";

                string[]   padNames     = Input.GetJoystickNames();
                List <int> allowedSlots = new List <int>();
                for (int i = 0; i < padNames.Length; i++)
                {
                    if (padNames[i].ToUpper() == deviceName.ToUpper())
                    {
                        allowedSlots.Add(i);
                    }
                }
                newInput.allowedSlots = allowedSlots.ToArray();
            }


            controls[controlIndex].inputs.Add(newInput);

            BuildRebindingPanels();
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonInputDeviceInfo"/> class.
        /// </summary>
        /// <param name="name">The device name.</param>
        /// <param name="deviceType">The type of device.</param>
        /// <param name="className">Class name of the device.</param>
        /// <param name="hidPath">Human interface device path.</param>
        /// <exception cref="System.ArgumentException">Thrown when the <paramref name="name"/>, <paramref name="className"/> or <paramref name="hidPath"/> are NULL or empty.</exception>
        /// <exception cref="System.ArgumentNullException"></exception>
        protected GorgonInputDeviceInfo(string name, InputDeviceType deviceType, string className, string hidPath)
            : base(name)
        {
            if (string.IsNullOrWhiteSpace(className))
            {
                throw new ArgumentException(Resources.GORINP_PARAMETER_NULL_EMPTY, "className");
            }

            if (string.IsNullOrWhiteSpace(hidPath))
            {
                throw new ArgumentException(Resources.GORINP_PARAMETER_NULL_EMPTY, "hidPath");
            }

            InputDeviceType = deviceType;
            ClassName       = className;
            HIDPath         = hidPath;
            UUID            = Guid.NewGuid();
        }
Ejemplo n.º 28
0
        internal VidPidInfo(int vid, int pid, string name = "Generic DS4", InputDeviceType inputDevType = InputDeviceType.DS4,
                            VidPidFeatureSet featureSet   = VidPidFeatureSet.DefaultDS4, CheckConnectionDelegate checkConnection = null)
        {
            this.vid          = vid;
            this.pid          = pid;
            this.name         = name;
            this.inputDevType = inputDevType;
            this.featureSet   = featureSet;

            if (checkConnection == null)
            {
                this.checkConnection = DS4Device.HidConnectionType;
            }
            else
            {
                this.checkConnection = checkConnection;
            }
        }
Ejemplo n.º 29
0
 private void SetFlag(InputDeviceType type, bool active)
 {
     if (type == InputDeviceType.Head)
     {
         activeHead = active;
     }
     else if (type == InputDeviceType.BT3Dof)
     {
         activeBT3Dof = active;
     }
     else if (type == InputDeviceType.KS)
     {
         activeKS = active;
     }
     else if (type == InputDeviceType.GGT26Dof)
     {
         activeGGT26Dof = active;
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Finds any device of this type.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="predicate"></param>
        /// <returns></returns>
        public InputDeviceDescriptor Find(InputDeviceType type, Predicate <InputDeviceDescriptor> predicate)
        {
            InputDeviceDescriptor[] descs = SupportedDevices;
            for (int i = 0; i < descs.Length; i++)
            {
                if (descs[i].DeviceType != type)
                {
                    continue;
                }

                // We check predicate.
                if (predicate(descs[i]))
                {
                    return(descs[i]);
                }
            }

            return(null);
        }
Ejemplo n.º 31
0
 protected InputPacket(InputDeviceType setType)
 {
     Type = setType;
 }