Ejemplo n.º 1
0
        protected virtual bool IsUseButtonDown()
        {
            if (DialogueManager.IsDialogueSystemInputDisabled())
            {
                return(false);
            }

            // First check for button down to remember what was selected at the time:
            if (!string.IsNullOrEmpty(useButton) && DialogueManager.getInputButtonDown(useButton))
            {
                clickedDownOn = selection;
            }

            // Check for use key or button (only if releasing button on same selection):
            if ((useKey != KeyCode.None) && InputDeviceManager.IsKeyDown(useKey))
            {
                return(true);
            }
            if (!string.IsNullOrEmpty(useButton))
            {
                if (DialogueManager.instance != null && DialogueManager.getInputButtonDown == DialogueManager.instance.StandardGetInputButtonDown)
                {
                    return(InputDeviceManager.IsButtonUp(useButton) && (selection == clickedDownOn));
                }
                else
                {
                    return(DialogueManager.GetInputButtonDown(useButton));
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public UdpVoiceHandler(ConcurrentDictionary <string, SRClient> clientsList, string guid, IPAddress address,
                               int port, OpusDecoder decoder, AudioManager audioManager, InputDeviceManager inputManager,
                               AudioManager.VOIPConnectCallback voipConnectCallback)
        {
            // _decoder = decoder;
            _audioManager = audioManager;

            _clientsList    = clientsList;
            _guidAsciiBytes = Encoding.ASCII.GetBytes(guid);

            _guid    = guid;
            _address = address;
            _port    = port;

            _serverEndpoint = new IPEndPoint(_address, _port);

            _inputManager = inputManager;

            _voipConnectCallback = voipConnectCallback;

            _updateTimer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(5)
            };
            _updateTimer.Tick += UpdateVOIPStatus;
            _updateTimer.Start();
        }
Ejemplo n.º 3
0
    private void ShootBullet()
    {
        if (lastShootTime_Bullet + shootDelay_Bullet > Time.time)
        {
            return;
        }

        //Rumble
        InputDevice device = InputDeviceManager.GetPlayerDevice(playerInput.GetPlayerIndex());

        RumbleManager.Instance.StartRumble(device, .1f, .15f, .015f);

        float      spreadOffset   = Random.Range(-currentSpread / 2f, currentSpread / 2f);
        Quaternion spreadRotation = firePoint.rotation * Quaternion.Euler(0f, spreadOffset, 0f);

        GameObject tempBullet = Instantiate(bulletPrefab, firePoint.position, spreadRotation, projectileContainer);
        Rigidbody  bulletRb   = tempBullet.GetComponent <Rigidbody>();


        bulletRb.AddForce(tempBullet.transform.forward * shootForce_Bullet);
        lastShootTime_Bullet = Time.time;

        playerAudioSource.PlayOneShot(shootClip_Bullet, shootClipScale_Bullet);
        SwitchToAR();
    }
Ejemplo n.º 4
0
        public MainWindow(CommandRunner commandRunner, InputDeviceManager inputDeviceManager)
        {
            this.commandRunner = commandRunner;
            InitializeComponent();
            var helper = new WindowInteropHelper(this);

            WindowHandleStore.Handle = helper.EnsureHandle();
        }
Ejemplo n.º 5
0
 private void OnJoinGame(CallbackContext ctx)
 {
     if (InputDeviceManager.AddPlayer(ctx.control.device))
     {
         int playerNumber = InputDeviceManager.GetPlayerNumber(ctx.control.device);
         playerProps[playerNumber - 1].SetActive(true);
         playerTexts[playerNumber - 1].SetActive(false);
         Debug.Log("Player " + playerNumber + " joined game");
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// game-specific content.
        /// </summary>
        protected override void UnloadContent()
        {
            //Context.Instance.SaveAppSettings();
            // TODO: Unload any non ContentManager content here
            //screen.UnloadContent();
#if ANDROID
            InputDeviceManager.UnloadAll();
#endif
            _engine.Destroy();
        }
Ejemplo n.º 7
0
        private void OnControllerConnectedEvent(ControllerStatusChangedEventArgs obj)
        {
            bool flag = false;

            if (LocalPlayer.Create)
            {
                LocalPlayer.Create.BeginCoolDown();
            }
            Debug.Log("OnControllerConnectedEvent");
            IList <Player> allPlayers = ReInput.players.AllPlayers;

            for (int i = 1; i < allPlayers.Count; i++)
            {
                Player player = allPlayers[i];
                bool   flag2  = player.controllers.ContainsController(obj.controllerType, obj.controllerId);
                bool   flag3  = InputDeviceManager.UseDevice(ReInput.controllers.GetController(obj.controllerType, obj.controllerId).hardwareIdentifier);
                if (!flag2 && flag3)
                {
                    flag = true;
                    Debug.Log(string.Concat(new object[]
                    {
                        "Adding controller to player ",
                        i,
                        " (",
                        player.name,
                        ")"
                    }));
                    player.controllers.AddController(obj.controllerType, obj.controllerId, false);
                }
                else if (flag2 && !flag3)
                {
                    flag = true;
                    Debug.Log(string.Concat(new object[]
                    {
                        "Removing controller to player ",
                        i,
                        " (",
                        player.name,
                        ")"
                    }));
                    player.controllers.RemoveController(obj.controllerType, obj.controllerId);
                }
            }
            if (flag && !InputMapping.holdLoadingMaps)
            {
                if (LocalPlayer.Inventory && LocalPlayer.Inventory.CurrentView == PlayerInventory.PlayerViews.World)
                {
                    base.Invoke("LoadAllMaps", 0.5f);
                }
                else
                {
                    this.LoadAllMaps();
                }
            }
        }
Ejemplo n.º 8
0
    private void OnLeaveGame(CallbackContext ctx)
    {
        int playerNumber = InputDeviceManager.GetPlayerNumber(ctx.control.device);

        if (InputDeviceManager.RemovePlayer(ctx.control.device))
        {
            playerProps[playerNumber - 1].SetActive(false);
            playerTexts[playerNumber - 1].SetActive(true);
            Debug.Log("Player " + playerNumber + " left game");
        }
    }
 void Update()
 {
     if (InputDeviceManager.IsKeyDown(menuKey) && !DialogueManager.isConversationActive && !IsQuestLogOpen())
     {
         SetMenuStatus(!isMenuOpen);
     }
     if (lockCursorDuringPlay)
     {
         CursorControl.SetCursorActive(DialogueManager.isConversationActive || isMenuOpen || IsQuestLogOpen());
     }
 }
Ejemplo n.º 10
0
 private void OnEnable()
 {
     if (!isRegistered)
     {
         isRegistered = true;
         didIRegister = true;
         _controls.Enable();
         InputDeviceManager.RegisterInputAction("Confirm", _controls.UI.Submit);
         InputDeviceManager.RegisterInputAction("Back", _controls.UI.Cancel);
     }
 }
Ejemplo n.º 11
0
 void LateUpdate()
 {
     if (UsesKeyboard == true && Input.GetKeyDown(ToggleKeycode))
     {
         Toggle();
     }
     else if (CloseOnEsc == true && InputDeviceManager.IsButtonDown("Cancel"))
     {
         Close();
     }
 }
Ejemplo n.º 12
0
 private void OnDisable()
 {
     //PlayerPositionManager.Position = transform.position;
     if (didIRegister)
     {
         isRegistered = false;
         didIRegister = false;
         _controls.Disable();
         InputDeviceManager.UnregisterInputAction("Confirm");
         InputDeviceManager.UnregisterInputAction("Back");
     }
 }
Ejemplo n.º 13
0
 void OnEnable()
 {
     if (!isRegistered)
     {
         isRegistered = true;
         didIRegister = true;
         controls.Enable();
         InputDeviceManager.RegisterInputAction("Horizontal", controls.DemoActionMap.Horizontal);
         InputDeviceManager.RegisterInputAction("Vertical", controls.DemoActionMap.Vertical);
         InputDeviceManager.RegisterInputAction("Fire1", controls.DemoActionMap.Fire1);
     }
 }
Ejemplo n.º 14
0
 void OnDisable()
 {
     if (didIRegister)
     {
         isRegistered = false;
         didIRegister = false;
         controls.Disable();
         InputDeviceManager.UnregisterInputAction("Horizontal");
         InputDeviceManager.UnregisterInputAction("Vertical");
         InputDeviceManager.UnregisterInputAction("Fire1");
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Checks whether the player has just pressed the use button.
 /// </summary>
 /// <returns>
 /// <c>true</c> if the use button/key is down; otherwise, <c>false</c>.
 /// </returns>
 protected virtual bool IsUseButtonDown()
 {
     if (DialogueManager.IsDialogueSystemInputDisabled())
     {
         return(false);
     }
     if (enableTouch && IsTouchDown())
     {
         return(true);
     }
     return(((useKey != KeyCode.None) && InputDeviceManager.IsKeyDown(useKey)) ||
            (!string.IsNullOrEmpty(useButton) && DialogueManager.GetInputButtonDown(useButton)));
 }
Ejemplo n.º 16
0
 void Update()
 {
     if (InputDeviceManager.IsKeyDown(menuKey) && !DialogueManager.isConversationActive && !IsQuestLogOpen())
     {
         SetMenuStatus(!isMenuOpen);
     }
     // If you want to lock the cursor during gameplay, add ShowCursorOnConversation to the Player,
     // and uncomment the code below:
     //if (!DialogueManager.isConversationActive && !isMenuOpen && !IsQuestLogOpen ())
     //{
     //	Screen.lockCursor = true;
     //}
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Adds a device manager.
        /// Only one instance of a given type can be added. An error will be raised if
        /// you try to add more than one.
        /// </summary>
        /// <param name="inputDeviceManager">The device manager to add.</param>
        public void AddDeviceManager(InputDeviceManager deviceManager)
        {
            AssertIsSetup();

            var type = deviceManager.GetType();

            if (deviceManagerTable.ContainsKey(type))
            {
                return;
            }

            deviceManagers.Add(deviceManager);
            deviceManagerTable.Add(type, deviceManager);
        }
Ejemplo n.º 18
0
        public UdpVoiceHandler(ConcurrentDictionary <string, SRClient> clientsList, string guid, IPAddress address, int port, OpusDecoder decoder, AudioManager audioManager, InputDeviceManager inputManager)
        {
            _decoder      = decoder;
            _audioManager = audioManager;

            _clientsList    = clientsList;
            _guidAsciiBytes = Encoding.ASCII.GetBytes(guid);

            _guid    = guid;
            _address = address;
            _port    = port;

            _inputManager = inputManager;
        }
Ejemplo n.º 19
0
 protected override void Update()
 {
     if (m_isAwaitingInput && !DialogueManager.IsDialogueSystemInputDisabled())
     {
         if (InputDeviceManager.IsKeyDown(acceptKey))
         {
             AcceptTextInput();
         }
         else if (InputDeviceManager.IsKeyDown(cancelKey))
         {
             CancelTextInput();
         }
     }
 }
        private void InitMicCapture(string guid, IPAddress ipAddress, int port, InputDeviceManager inputManager)
        {
            if (_audioInputSingleton.MicrophoneAvailable)
            {
                try
                {
                    var device = (MMDevice)_audioInputSingleton.SelectedAudioInput.Value;

                    if (device == null)
                    {
                        device = WasapiCapture.GetDefaultCaptureDevice();
                    }

                    device.AudioEndpointVolume.Mute = false;

                    _wasapiCapture                   = new WasapiCapture(device, true);
                    _wasapiCapture.ShareMode         = AudioClientShareMode.Shared;
                    _wasapiCapture.DataAvailable    += WasapiCaptureOnDataAvailable;
                    _wasapiCapture.RecordingStopped += WasapiCaptureOnRecordingStopped;

                    _udpVoiceHandler =
                        new UdpVoiceHandler(guid, ipAddress, port, this, inputManager);
                    var voiceSenderThread = new Thread(_udpVoiceHandler.Listen);

                    voiceSenderThread.Start();

                    _wasapiCapture.StartRecording();

                    _subs.Add(MessageHub.Instance.Subscribe <SRClient>(RemoveClientBuffer));
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "Error starting audio Input - Quitting! " + ex.Message);

                    ShowInputError("Problem initialising Audio Input!");

                    Environment.Exit(1);
                }
            }
            else
            {
                //no mic....
                _udpVoiceHandler =
                    new UdpVoiceHandler(guid, ipAddress, port, this, inputManager);
                _subs.Add(MessageHub.Instance.Subscribe <SRClient>(RemoveClientBuffer));
                var voiceSenderThread = new Thread(_udpVoiceHandler.Listen);
                voiceSenderThread.Start();
            }
        }
Ejemplo n.º 21
0
        protected virtual Vector3 GetSelectionPoint()
        {
            switch (selectAt)
            {
            case SelectAt.MousePosition:
                return(InputDeviceManager.GetMousePosition());

            case SelectAt.CustomPosition:
                return(CustomPosition);

            default:
            case SelectAt.CenterOfScreen:
                return(new Vector3(Screen.width / 2, Screen.height / 2));
            }
        }
Ejemplo n.º 22
0
 public MainWindowViewModel(MainWindowModel model, InputDeviceManager inputDeviceManager) : base(model)
 {
     this.inputDeviceManager = inputDeviceManager;
     foreach (var inputDeviceHolder in inputDeviceManager.GetInputDevices())
     {
         foreach (var inputDevice in inputDeviceHolder.GetInputDevices().Where(d => d.InputMethod == InputDeviceMethod.DirectInput).OfType <DirectInputDevice>())
         {
             Model.DirectInputs.Add(inputDevice);
         }
         foreach (var inputDevice in inputDeviceHolder.GetInputDevices().Where(d => d.InputMethod == InputDeviceMethod.RawInput).OfType <RawInputDevice>())
         {
             Model.RawInputs.Add(inputDevice);
         }
     }
 }
        public TCPVoiceHandler(ConcurrentDictionary <string, SRClient> clientsList, string guid, IPAddress address,
                               int port, OpusDecoder decoder, AudioManager audioManager, InputDeviceManager inputManager, AudioManager.VOIPConnectCallback voipConnectCallback)
        {
            // _decoder = decoder;
            _audioManager = audioManager;

            _clientsList    = clientsList;
            _guidAsciiBytes = Encoding.ASCII.GetBytes(guid);

            _guid    = guid;
            _address = address;
            _port    = port + 1;

            _inputManager = inputManager;

            _voipConnectCallback = voipConnectCallback;
        }
        private void Modifier_Click(object sender, RoutedEventArgs e)
        {
            ModifierButtonClear.IsEnabled = false;
            ModifierButton.IsEnabled      = false;

            InputDeviceManager.AssignButton(device =>
            {
                ModifierButtonClear.IsEnabled = true;
                ModifierButton.IsEnabled      = true;

                ModifierDevice.Text = device.DeviceName;
                ModifierText.Text   = device.Button < 128 ? device.Button.ToString() : "POV " + (device.Button - 127);
                //output POV info;

                device.InputBind = ModifierBinding;

                SettingsStore.Instance.SetControlSetting(device);
            });
        }
        private void Modifier_Click(object sender, RoutedEventArgs e)
        {
            ModifierButtonClear.IsEnabled = false;
            ModifierButton.IsEnabled      = false;

            InputDeviceManager.AssignButton(device =>
            {
                ModifierButtonClear.IsEnabled = true;
                ModifierButton.IsEnabled      = true;

                ModifierDevice.Text = device.DeviceName;
                ModifierText.Text   = device.Button < 128 ? device.Button.ToString() : "POV " + (device.Button - 127);
                //output POV info;

                device.InputBind = ModifierBinding;

                InputDeviceManager.InputConfig.InputDevices[(int)ModifierBinding] = device;
                InputDeviceManager.InputConfig.WriteInputRegistry(ModifierBinding, device);
            });
        }
Ejemplo n.º 26
0
        private void Device_Click(object sender, RoutedEventArgs e)
        {
            DeviceClear.IsEnabled  = false;
            DeviceButton.IsEnabled = false;


            InputDeviceManager.AssignButton(device =>
            {
                DeviceClear.IsEnabled  = true;
                DeviceButton.IsEnabled = true;

                Device.Text     = device.DeviceName;
                DeviceText.Text = device.Button < 128 ? (device.Button + 1).ToString() : "POV " + (device.Button - 127);
                //output POV info;

                device.InputBind = ControlInputBinding;

                GlobalSettingsStore.Instance.ProfileSettingsStore.SetControlSetting(device);
            });
        }
        public UdpVoiceHandler(string guid, IPAddress address, int port, OpusDecoder decoder, AudioManager audioManager,
                               InputDeviceManager inputManager)
        {
            // _decoder = decoder;
            _audioManager   = audioManager;
            _guidAsciiBytes = Encoding.ASCII.GetBytes(guid);

            _guid    = guid;
            _address = address;
            _port    = port;

            _serverEndpoint = new IPEndPoint(_address, _port);

            _inputManager = inputManager;

            _updateTimer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(5)
            };
            _updateTimer.Tick += UpdateVOIPStatus;
            _updateTimer.Start();
        }
Ejemplo n.º 28
0
    private void ShootRocket()
    {
        if (lastShootTime_Rocket + shootDelay_Rocket > Time.time)
        {
            return;
        }

        //Rumble
        InputDevice device = InputDeviceManager.GetPlayerDevice(playerInput.GetPlayerIndex());

        RumbleManager.Instance.StartRumble(device, .5f, .3f, .1f);

        GameObject tempRocket = Instantiate(rocketPrefab, firePoint.position, Quaternion.LookRotation(firePoint.forward), projectileContainer);
        Rigidbody  rocketRb   = tempRocket.GetComponent <Rigidbody>();

        rocketRb.AddForce(firePoint.forward * shootForce_Rocket);
        lastShootTime_Rocket = Time.time;

        playerAudioSource.PlayOneShot(shootClip_Rocket, shootClipScale_Rocket);
        SwitchToRocket();
    }
        private void Device_Click(object sender, RoutedEventArgs e)
        {
            DeviceClear.IsEnabled  = false;
            DeviceButton.IsEnabled = false;


            InputDeviceManager.AssignButton(device =>
            {
                DeviceClear.IsEnabled  = true;
                DeviceButton.IsEnabled = true;

                Device.Text     = device.DeviceName;
                DeviceText.Text = device.Button < 128 ? device.Button.ToString() : "POV " + (device.Button - 127);
                //output POV info;

                device.InputBind = ControlInputBinding;

                InputDeviceManager.InputConfig.InputDevices[ControlInputBinding] = device;
                InputDeviceManager.InputConfig.WriteInputRegistry(ControlInputBinding, device);
            });
        }
Ejemplo n.º 30
0
    private void SpawnPlayers()
    {
        int playerCount = InputDeviceManager.GetCurrentPlayerCount();

        //If no current players, use the default
        if (playerCount == 0 && defaultPlayer != null)
        {
            int playerIndex = 0;
            if (Gamepad.current != null)
            {
                InputDeviceManager.AddPlayer(Gamepad.current.device);
            }

            defaultPlayer.GetComponent <PlayerInputController>().SetPlayerIndex(playerIndex);

            defaultPlayer.transform.position = playerSpawns[0].position;
        }
        else
        {
            if (defaultPlayer != null)
            {
                Destroy(defaultPlayer);
            }
            int maxPlayers = InputDeviceManager.GetMaxPlayerCount();
            for (int i = 0; i < maxPlayers; i++)
            {
                if (InputDeviceManager.GetPlayerDevice(i) != null)
                {
                    int        playerIndex = i;
                    GameObject tempPlayer  = PlayerInput.Instantiate(playerPrefab, playerIndex, "Gamepad", -1, InputDeviceManager.GetPlayerDevice(playerIndex)).gameObject;
                    tempPlayer.gameObject.GetComponent <PlayerInputController>().SetPlayerIndex(playerIndex);

                    Transform playerObj = tempPlayer.transform.root;
                    playerObj.position = playerSpawns[i].position;
                    playerObj.parent   = playerContainer;
                }
            }
        }
    }