public void AddPlayer(int id, InputDeviceCollection deviceCollection) { GameObject player = Instantiate(playerPrefab, new Vector3(Random.Range(-3f, 3f), 0, Random.Range(-3f, 3f)), Quaternion.identity); player.GetComponent <PlayerInputController>().Initialize(deviceCollection); playersById[id] = player; }
// -Public API- public AnyInputDevice(InputDeviceCollection devices) { // We look through all the registered devices as there might have already been some devices available // and we register them to our listener devices.OnDeviceAdded += OnDeviceAdded; foreach (IInputDevice device in devices) { m_Listeners.Add(new InputDeviceListener(device, OnInputReceived, RemoveListener)); } }
private void ParsecUnityController_OnGuestConnected(ParsecGaming.Parsec.ParsecGuest guest, InputDeviceCollection deviceCollection) { AddPlayer((int)guest.id, deviceCollection); }
public void Initialize(InputDeviceCollection deviceCollection) { deviceCollection.OnUseUnpairedDevice += DeviceCollection_OnUseUnpairedDevice; this.deviceCollection = deviceCollection; }
private static void showDevices() { InputDeviceCollection dList = null; ////holds keyboards InputDeviceCollection dList2 = null; ////holds game controllers dList = DirectInput.GetDevices(DeviceClass.Keyboard, DeviceEnumerationFlags.AttachedOnly); ////enumerator for keyboards dList2 = DirectInput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly); ////enumerator for all game controllers DeviceInstance[] devList = null; devList = (DeviceInstance[])(Array.CreateInstance(typeof(DeviceInstance), (dList2 == null) ? 1 : 2)); foreach (DeviceInstance d in dList) { devList[0] = d; break; } if (dList2 != null) { foreach (DeviceInstance d in dList2) { devList[1] = d; break; } } string[] devListSTR = new string[(dList2 == null) ? 1 : 2]; devListSTR[0] = "mainmenu_5_1_1.wav"; if (dList2 != null) { devListSTR[1] = "mainmenu_5_1_2.wav"; } int mindex = Common.sVGenerateMenu(null, devListSTR); if (mindex == -1) { return; } ////exit menu if (mindex > 0) { ////chose joystick ////so config it dxInput.DInputInit(Common.mainGUI.Handle, devList[mindex].InstanceGuid); configureJS(devList[mindex].InstanceGuid); KeyMap.readFromFile(); SecondarySoundBuffer confirm = DSound.LoadSound(DSound.NSoundPath + "\\gce.wav"); DSound.PlaySound(confirm, true, false); while (DSound.isPlaying(confirm)) { Thread.Sleep(10); } DSound.unloadSound(confirm); confirm = null; } else { if (dxInput.JSDevice != null) { dxInput.JSDevice.Unacquire(); dxInput.JSDevice = null; } //if !null KeyMap.readFromFile(); } //if chose keyboard }
private void ParsecUnityController_OnGuestConnected(ParsecGaming.Parsec.ParsecGuest guest, InputDeviceCollection deviceCollection) { AddPlayer((int)guest.id); deviceCollection.OnUseDifferentDevice += (device) => UpdatePlayerInputDevices((int)guest.id, device); }