Beispiel #1
0
        void OnDeviceChange(InputDevice device, InputDeviceChange change)
        {
            var midiDevice = device as Minis.MidiDevice;

            if (midiDevice == null)
            {
                return;
            }

            // Channel matching
            if (_channel >= 0 && midiDevice.channel != _channel)
            {
                return;
            }

            // Product name matching
            if (!string.IsNullOrEmpty(_productName) &&
                !device.description.product.Contains(_productName))
            {
                return;
            }

            // Do pairing.
            InputUser.PerformPairingWithDevice(device, GetComponent <PlayerInput>().user);
        }
Beispiel #2
0
        private void OnDeviceChange(InputDevice device, InputDeviceChange change)
        {
            switch (change)
            {
            case InputDeviceChange.Added:
                Debug.Log("Input device added");
                break;

            case InputDeviceChange.Removed:
                Debug.Log("Input device removed");
                break;

            case InputDeviceChange.Enabled:
                Debug.Log("Input device enabled");
                break;

            case InputDeviceChange.Disabled:
                Debug.Log("Input device disabled");
                break;

            default:
                // not sure if we need to handle the rest of these
                break;
            }
        }
Beispiel #3
0
 private void OnDeviceChange(InputDevice device, InputDeviceChange change)
 {
     if (change == InputDeviceChange.Added || change == InputDeviceChange.Reconnected)
     {
         DisableConflictingDevice(device);
     }
 }
Beispiel #4
0
    private static void DeviceChange(InputDevice device, InputDeviceChange change)
    {
        switch (change)
        {
        case InputDeviceChange.Added:
            // New Device.
            Debug.Log("Added: " + device.name);
            break;

        case InputDeviceChange.Disconnected:
            // Device got unplugged.
            Debug.Log("Disconnected: " + device.name);
            break;

        case InputDeviceChange.Reconnected:
            // Plugged back in.
            Debug.Log("Reconnected: " + device.name);
            break;

        case InputDeviceChange.Removed:
            // Remove from Input System entirely; by default, Devices stay in the system once discovered.
            Debug.Log("Removed: " + device.name);
            break;

        default:
            // See InputDeviceChange reference for other event types.
            break;
        }
    }
Beispiel #5
0
 public virtual void OnDeviceChanged(InputDevice device, InputDeviceChange change)
 {
     if (device is Gamepad)
     {
         if (change == InputDeviceChange.Added || change == InputDeviceChange.Reconnected)
         {
             GameManager.activeCursorEntry.rectTrs.gameObject.SetActive(false);
             if (VirtualKeyboard.Instance != null)
             {
                 VirtualKeyboard.instance.outputToInputField.readOnly = true;
             }
         }
         else if (change == InputDeviceChange.Removed || change == InputDeviceChange.Disconnected)
         {
             GameManager.activeCursorEntry.rectTrs.gameObject.SetActive(true);
             if (VirtualKeyboard.Instance != null)
             {
                 VirtualKeyboard.instance.outputToInputField.readOnly = false;
             }
         }
         foreach (_Text text in _Text.instances)
         {
             text.UpdateText();
         }
     }
 }
Beispiel #6
0
        private void OnDeviceChange(InputDevice device, InputDeviceChange change)
        {
            // If someone removed our simulated touchscreen, disable touch simulation.
            if (device == simulatedTouchscreen && change == InputDeviceChange.Removed)
            {
                Disable();
                return;
            }

            switch (change)
            {
            case InputDeviceChange.Added:
            {
                if (device is Pointer pointer)
                {
                    if (device is Touchscreen)
                    {
                        return;     ////TODO: decide what to do
                    }
                    AddPointer(pointer);
                }
                break;
            }

            case InputDeviceChange.Removed:
            {
                if (device is Pointer pointer)
                {
                    RemovePointer(pointer);
                }
                break;
            }
            }
        }
Beispiel #7
0
        private void OnGamepadChange(Gamepad gamepad, InputDeviceChange change)
        {
            switch (change)
            {
            case InputDeviceChange.Added:
                AddGamepad(gamepad);
                break;

            case InputDeviceChange.Enabled:
                Debug.LogWarning("Unhandled gamepad enabled");
                break;

            case InputDeviceChange.Removed:
                RemoveGamepad(gamepad);
                break;

            case InputDeviceChange.Disabled:
                Debug.LogWarning("Unhandled gamepad disabled");
                break;

            case InputDeviceChange.StateChanged:
                break;

            default:
                Debug.LogWarning($"Unhandled gamepad change: {change}");
                break;
            }
        }
Beispiel #8
0
    private void OnControllerChange(InputDevice device, InputDeviceChange change)
    {
        Debug.Log(Gamepad.current.name);
        switch (change)
        {
        case InputDeviceChange.Added:
            // New Device.
            foreach (Ship s in instancePlayers)
            {
                SpaceShipController c = s.GetComponent <SpaceShipController>();
                if (!c.Controller.Assigned)
                {
                    c.Controller.AssignController(device);
                }
            }
            break;

        case InputDeviceChange.Disconnected:

            // Device got unplugged.
            break;

        case InputDeviceChange.Reconnected:
            // Plugged back in.
            break;

        case InputDeviceChange.Removed:
            // Remove from Input System entirely; by default, Devices stay in the system once discovered.
            break;

        default:
            // See InputDeviceChange reference for other event types.
            break;
        }
    }
    /// <summary>
    /// Updates state of device
    /// </summary>
    /// <param name="arg1"></param>
    /// <param name="arg2"></param>
    private static void InputSystem_onDeviceChange(InputDevice arg1, InputDeviceChange arg2)
    {
        if (prevInputDevice == arg1 && prevInputDeviceChange == arg2)
        {
            return;
        }

        prevInputDevice       = arg1;
        prevInputDeviceChange = arg2;

        switch (arg2)
        {
        case InputDeviceChange.Added:
            Debug.Log($" Added {arg1.name} with DeviceId: {arg1.deviceId} and Path: {arg1.path} ");
            EvaluateDevice(arg1);
            break;

        case InputDeviceChange.Removed:
            Debug.Log($" Removed {arg1.name} with DeviceId: {arg1.deviceId} and Path: {arg1.path} ");
            RemoveDevice(arg1);
            break;

        case InputDeviceChange.Disconnected:
            break;

        case InputDeviceChange.Reconnected:
            break;

        default:
            break;
        }
    }
Beispiel #10
0
        private void SendDeviceChange(InputDevice device, InputDeviceChange change)
        {
            if (m_Subscribers == null)
            {
                return;
            }

            // Don't mirror remoted devices to other remotes.
            if (device.remote)
            {
                return;
            }

            Message msg;

            switch (change)
            {
            case InputDeviceChange.Added:
                msg = NewDeviceMsg.Create(this, device);
                break;

            case InputDeviceChange.Removed:
                msg = RemoveDeviceMsg.Create(this, device);
                break;

            case InputDeviceChange.UsageChanged:
                msg = ChangeUsageMsg.Create(this, device);
                break;

            default:
                return;
            }

            Send(msg);
        }
Beispiel #11
0
 void DeviceChangedHandler(InputDevice device, InputDeviceChange change)
 {
     if (gamepadassigned < players.Length)
     {
         Assign();
     }
 }
 private void OnDeviceChange(InputDevice device, InputDeviceChange change)
 {
     if (device is Gamepad)
     {
         UpdateLayout();
     }
 }
    public void onInputDeviceChange(InputDevice device, InputDeviceChange change)
    {
        var mydevice = device as myDevice;

        if (mydevice != null)
        {
            switch (change)
            {
            case InputDeviceChange.Added:
                connected += 1;
                break;

            case InputDeviceChange.Removed:
                connected -= 1;
                break;

            case InputDeviceChange.ConfigurationChanged:
                break;

            case InputDeviceChange.Disconnected:
                connected -= 1;
                break;

            case InputDeviceChange.Reconnected:
                connected += 1;
                break;
            }
            if (connected != null)
            {
                changeConnectedText();
            }
        }
    }
 public void UnregistInputDeviceChange(InputDeviceChange ev)
 {
     if (ev != null)
     {
         onInputChanged -= ev;
     }
 }
 public void RegistOnInputDeviceChange(InputDeviceChange ev)
 {
     if (ev != null)
     {
         onInputChanged += ev;
     }
 }
Beispiel #16
0
    public void OnDeviceChange(InputDevice inputDevice, InputDeviceChange inputDeviceChange)
    {
        if (isActive && inputDeviceChange == InputDeviceChange.Added)
        {
            for (int i = 0; i < Gamepad.all.Count; i++)
            {
                if (inputDevice == Gamepad.all[i].device)
                {
                    PlayerInput gamepadInput = PlayerInput.Instantiate(controllerUIEntity, playerInputList.Count + 1, "Gamepad", -1, inputDevice);
                    gamepadInput.transform.SetParent(controlSettingsCanvas.transform);
                    gamepadInput.transform.GetComponent <SpriteRenderer>().sprite               = gamepadSprite;
                    gamepadInput.transform.GetComponent <ControllerDeviceUI>().assignedDevice   = inputDevice;
                    gamepadInput.transform.GetComponent <ControllerDeviceUI>().assignedScheme   = "Gamepad";
                    gamepadInput.transform.GetComponent <ControllerDeviceUI>().assignedDeviceID = inputDevice.deviceId;
                    playerInputList.Add(gamepadInput.gameObject);
                    OrderDeviceList();
                    i = Gamepad.all.Count;
                }
            }
        }

        if (!isActive && inputDeviceChange == InputDeviceChange.Removed && (inputDevice.deviceId == p1DeviceID || inputDevice.deviceId == p2DeviceID))
        {
            OnActivate();
        }
    }
    public void OnDeviceChange(InputDevice device, InputDeviceChange change)
    {
        switch (change)
        {
        case InputDeviceChange.Added:
            AddNewPlayer(device);
            print(device.displayName + " added!");
            // New Device.
            break;

        case InputDeviceChange.Disconnected:
            print(device.displayName + " disconnected!");
            // Device got unplugged.
            break;

        case InputDeviceChange.Reconnected:
            print(device.displayName + " reconnected!");
            // Plugged back in.
            break;

        case InputDeviceChange.Removed:
            print(device.displayName + " removed!");
            // Remove from Input System entirely; by default, Devices stay in the system once discovered.
            break;

        case InputDeviceChange.Destroyed:
            print(device.displayName + " destroyed!");
            RemovePlayer(device);
            break;

        default:
            // See InputDeviceChange reference for other event types.
            break;
        }
    }
 void OnDeviceChange(InputDevice device, InputDeviceChange change)
 {
     if (change == InputDeviceChange.Added)
     {
         UpdateUsages(device);
     }
 }
Beispiel #19
0
 private void OnDeviceChange(InputDevice device, InputDeviceChange change)
 {
     if (device is Gamepad)
     {
         OnGamepadChange((Gamepad)device, change);
         return;
     }
 }
Beispiel #20
0
 private void OnDeviceChange(InputDevice device, InputDeviceChange change)
 {
     // Update tree if devices are added or removed.
     if (change == InputDeviceChange.Added || change == InputDeviceChange.Removed)
     {
         Refresh();
     }
 }
 private void OnDeviceChange(InputDevice device, InputDeviceChange change)
 {
     switch (change)
     {
     case InputDeviceChange.Added:
         OnAddDevice(device);
         return;
     }
 }
Beispiel #22
0
 void OnDeviceChanged(UnityEngine.InputSystem.InputDevice device, InputDeviceChange change)
 {
     if (change == InputDeviceChange.Added)
     {
         leftTouchController  = (OculusTouchController)OculusTouchController.leftHand;
         rightTouchController = (OculusTouchController)OculusTouchController.rightHand;
         hmd = InputSystem.GetDevice <OculusHMD>();
     }
 }
Beispiel #23
0
        private void OnDeviceChanged(InputDevice inputDevice, InputDeviceChange inputDeviceChange)
        {
            Debug.LogWarning($"{inputDevice.displayName}: {inputDeviceChange}");

            switch (inputDeviceChange)
            {
            case InputDeviceChange.Added:

                if (connectedInputDevices.Contains(GetConnectedDevice(inputDevice)))
                {
                    Debug.LogError($"{GetConnectedDevice(inputDevice).Name} same device already connected!");
                    return;
                }

                connectedInputDevices.Add(new Connected_InputDevice(inputDevice));

                break;

            case InputDeviceChange.Removed:

                connectedInputDevices.Remove(GetConnectedDevice(inputDevice));

                break;

            case InputDeviceChange.Disconnected:

                break;

            case InputDeviceChange.Reconnected:

                break;

            case InputDeviceChange.Enabled:

                break;

            case InputDeviceChange.Disabled:

                break;

            case InputDeviceChange.UsageChanged:

                break;

            case InputDeviceChange.ConfigurationChanged:

                break;

            case InputDeviceChange.Destroyed:

                break;

            default:

                break;
            }
        }
 private void InputSystem_onDeviceChange(InputDevice arg1, InputDeviceChange arg2)
 {
     if (arg2 == InputDeviceChange.Disconnected)
     {
         Debug.LogError("in");
         inputLux.user.UnpairDevice(arg1);
         inputBan.user.UnpairDevice(arg1);
     }
 }
Beispiel #25
0
        void OnDeviceChanged(InputDevice device, InputDeviceChange change)
        {
            bool usingGamepad = InputManager.UsingGamepad;

            if (usingGamepad != previousUsingGamepad)
            {
                ToggleGos();
                previousUsingGamepad = usingGamepad;
            }
        }
        private void OnDeviceChange(InputDevice device, InputDeviceChange change)
        {
            if (device.id != m_DeviceId)
            {
                return;
            }

            m_Device = null;
            Repaint();
        }
Beispiel #27
0
    private void OnDeviceChange(InputDevice device, InputDeviceChange eventType)
    {
        if (Application.isPlaying)
        {
            // Check if it's a gamepad
            Gamepad controller = device as Gamepad;
            if (controller == null)
            {
                return;
            }

            // Handle device change
            if (eventType == InputDeviceChange.Added)
            {
                if (LocaL.Player.numPlayers < LocaL.Player.maxPlayers)
                {
                    for (int i = 0; i < players.Count; i++)
                    {
                        if (controller == players[i].gamepad)
                        {
                            // Somehow, the controller was already initialized so skip it
                            Debug.Log("Controller already initialized, no need to readd it.");
                            return;
                        }
                    }
                    LocaL.Player newPlayer = new LocaL.Player(controller);
                    Debug.Log("New controller connected!");
                    //newPlayer.Print();    // Additional player log
                    players.Add(newPlayer);
                    Debug.Log("Current players: " + players.Count + "/" + LocaL.Player.maxPlayers);
                    HandleNewPlayer(newPlayer, false);
                }
                else
                {
                    Debug.Log("New controller connected, but reached max players (" + LocaL.Player.maxPlayers.ToString() + ")!");
                    Debug.Log("Disconnect one of the connected controllers to be able to connect another one.");
                }
            }
            else if (eventType == InputDeviceChange.Disconnected || eventType == InputDeviceChange.Destroyed || eventType == InputDeviceChange.Removed)
            {
                Debug.Log("Controller disconnected!");
                for (int i = 0; i < players.Count; i++)
                {
                    if (controller.deviceId == players[i].gamepad.deviceId)
                    {
                        //players[i].Print();   // Additional player log
                        players.RemoveAt(i);
                        Debug.Log("Current players: " + players.Count + "/" + LocaL.Player.maxPlayers);
                        return;
                    }
                }
            }
        }
    }
Beispiel #28
0
    private void DeviceChange(InputDevice arg1, InputDeviceChange arg2)
    {
        if (arg2 == InputDeviceChange.Disconnected)
        {
            Paused = true;

            OnPause?.Invoke();
            //menuPause.SetActive(true);
            //EventSystem.current.SetSelectedGameObject(menuPause.GetComponentInChildren<UnityEngine.UI.Button>().gameObject);
        }
    }
        void OnDeviceChange(InputDevice device, InputDeviceChange change)
        {
            switch (change)
            {
            case InputDeviceChange.Added:
                SetDevice(device);
                return;

            case InputDeviceChange.Removed:
                SetDevice(device, false);
                return;
            }
        }
Beispiel #30
0
 private void OnDeviceChange(InputDevice device, InputDeviceChange change)
 {
     if (device is Keyboard kb)
     {
         if (change == InputDeviceChange.ConfigurationChanged)                           // keyboard layout change, remap main keys
         {
             SetupKeyboard(ImGui.GetIO(), kb);
         }
         if (Keyboard.current != _keyboard)                                              // keyboard device changed, setup again
         {
             SetupKeyboard(ImGui.GetIO(), Keyboard.current);
         }
     }
 }