コード例 #1
0
ファイル: ShowInputWindow.cs プロジェクト: ctinney94/GGJ2018
    private void Awake()
    {
        inputs = inputs == null?AssetDatabase.LoadAssetAtPath <InputSetup>("Assets/GameEssentials/Inputs/GamePad.asset") : inputs;

        UpdateInputManager.CreateInputs(inputs, controllerAmount, deadZone);
        Controller.SetControllerAmount(controllerAmount);
    }
コード例 #2
0
        public void Open(InputSetup setup)
        {
            var  req     = (ScreenCaptureRequest)setup.ObjectInput;
            bool directX = setup.Dx != null;

            _capture = new ScreenCaptureEngine(req, setup.Dx, sz => OnSizeChanged(sz, directX));
            SetConfig(req.InitialSize, directX);
        }
コード例 #3
0
    // Start is called before the first frame update

    private void Awake()
    {
        //singleton
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
        }
    }
コード例 #4
0
        public virtual void Open(InputSetup setup)
        {
            _queue?.Dispose();
            var contextSetup = (WebBrowserContextSetup)setup.ObjectInput;

            _size  = new Size(contextSetup.PageWidth, contextSetup.PageHeight);
            _queue = new InputBufferQueue("WebBrowserQueue", _streamer, MaxPackets, setup.Dx, contextSetup.PageWidth, contextSetup.PageHeight);

            CefServer.EnsureInit(new CefConfiguration
            {
                CachePathRoot    = Path.Combine(contextSetup.BaseFolder, "cache"),
                CachePathRequest = Path.Combine(contextSetup.BaseFolder, "cache\\request"),
                CachePathGlobal  = Path.Combine(contextSetup.BaseFolder, "cache\\global"),
                LogVerbose       = false,
                LogFile          = Path.Combine(contextSetup.BaseFolder, "wb.log")
            });

            if (_cefBrowser == null)
            {
                _cefBrowser = CefServer.CreateBrowser(setup.Input, contextSetup.Fps, this);
            }
            else
            {
                _cefBrowser.Load(setup.Input);
            }

            Config = new InputConfig(
                new InputStreamProperties[]
            {
                new InputStreamProperties
                {
                    CodecProps = new CodecProperties
                    {
                        codec_type            = AVMediaType.AVMEDIA_TYPE_VIDEO,
                        codec_id              = Core.Const.CODEC_ID_RAWVIDEO,
                        width                 = _size.Width,
                        height                = _size.Height,
                        bits_per_coded_sample = 4 * 8,
                        format                = setup.Dx == null ?  Core.Const.PIX_FMT_BGRA : Core.PIX_FMT_INTERNAL_DIRECTX,

                        extradata = new byte[1024]
                    }
                }
            }
                );
        }
コード例 #5
0
ファイル: ShowInputWindow.cs プロジェクト: ctinney94/GGJ2018
 void OnGUI()
 {
     GUILayout.Label("Generate Inputs", EditorStyles.boldLabel);
     GUILayout.Label(" ");
     controllerAmount = EditorGUILayout.IntSlider("Amount of Controllers", controllerAmount, 1, 8);
     GUILayout.Label("Controller Template File (Default is DualShock4)");
     inputs = EditorGUILayout.ObjectField(inputs, typeof(InputSetup), false) as  InputSetup;
     GUILayout.Label("Axis DeadZone (0 = none, 1 = full");
     deadZone = EditorGUILayout.Slider("Dead Zone", deadZone, 0, 1);
     GUILayout.Label("GamePad - switches face button names for ease of development");
     type = (ControllerType)GUILayout.Toolbar((int)type, new string[2] {
         "DualShock4", "Xbox"
     });
     if (GUILayout.Button("Press to Set up " + controllerAmount + " Controllers", EditorStyles.toolbarButton))
     {
         UpdateInputManager.CreateInputs(inputs, controllerAmount, deadZone);
         Controller.SetControllerAmount(controllerAmount);
         Controller.SetDeadZoneAmount(deadZone);
         Controller.SetControllerType(type);
     }
 }
コード例 #6
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            if (isFullScreen)
            {
                //Set Fullscreen
                graphics.PreferredBackBufferWidth  = GraphicsDevice.DisplayMode.Width;
                graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
                graphics.ApplyChanges();
                //Set Screen width and height
                ScreenWidth  = GraphicsDevice.DisplayMode.Width;
                ScreenHeight = GraphicsDevice.DisplayMode.Height;
            }
            else
            {
                graphics.PreferredBackBufferWidth  = 1200;
                graphics.PreferredBackBufferHeight = 600;
                graphics.ApplyChanges();
                ScreenWidth  = graphics.PreferredBackBufferWidth;
                ScreenHeight = graphics.PreferredBackBufferHeight;
            }



            //Initialize Managers
            spriteBatch = new SpriteBatch(GraphicsDevice);
            services.GetService <IResourceManager>().Initialize(Content);
            services.GetService <IEntityManager>().Initialize();
            services.GetService <ISceneManager>().Initialize();
            services.GetService <IComponentMaster>().Initialize();
            services.GetService <IRenderer>().Initialize();
            //Setup controls inputs for all the players
            InputSetup.SetupInputs();

            //Set the current gameMode
            gameMode = new BeetlesGameMode();



            base.Initialize();
        }
コード例 #7
0
        public override void Open(InputSetup setup)
        {
            var handle = PluginContextSetup.GetHandle();

            if (handle == IntPtr.Zero)
            {
                throw new InvalidOperationException($"PluginContextSetup returned Zero");
            }

            StringBuilder url = new StringBuilder(2001);

            int code = Plugin_GetUrl(handle, url, 2000);

            if (code != 0)
            {
                throw new InvalidOperationException($"Plugin_GetUrl returned {code}");
            }

            base.Open(setup with {
                Input = url.ToString()
            });
        }
コード例 #8
0
        public void Read(Packet packet, InputSetup setup)
        {
            var       loop       = setup.NoneResetingOptions.LoopbackOptions;
            SizeInt32 configSize = loop != null ? new SizeInt32 {
                Width = loop.Width, Height = loop.Height
            } : new SizeInt32 {
                Width = 0, Height = 0
            };

            _capture.Read(configSize, (b, bitPerPixel, width, height, sourceWidth, dxRes) =>
            {
                if (dxRes == null)
                {
                    return(packet.InitFromBuffer(b, bitPerPixel, width, height, sourceWidth, Core.GetCurrentTime(), true));
                }
                else
                {
                    packet.InitFromDirectX(dxRes, Core.GetCurrentTime());
                    return(true);
                }
            });
        }
コード例 #9
0
        public void Open(InputSetup setup)
        {
            var format = _audio.Open();

            Config = new InputConfig(new[]
            {
                new InputStreamProperties
                {
                    CodecProps = new CodecProperties
                    {
                        codec_type            = AVMediaType.AVMEDIA_TYPE_AUDIO,
                        codec_id              = 65557, //AV_CODEC_ID_PCM_F32BE
                        sample_rate           = format.SampleRate,
                        bits_per_coded_sample = 16,
                        bit_rate              = 16 * format.SampleRate * format.Channels,
                        channels              = format.Channels,
                        format    = 3,  // float, none-planar
                        extradata = new byte[1024]
                    }
                }
            });
        }
コード例 #10
0
 public static void CreateInputs(InputSetup _scriptable, int _controllers, float _deadZone)
 {
     ClearInputData();
     for (int i = 0; i < _controllers; i++)
     {
         foreach (InputSetup.JoystickAxis j in _scriptable.joystickAxis)
         {
             AddAxis(j, (i + 1), _deadZone);
         }
         foreach (InputSetup.Button b in _scriptable.buttons)
         {
             AddButton(b, (i + 1));
         }
     }
     foreach (InputSetup.JoystickAxis j in _scriptable.joystickAxis)
     {
         AddAxis(j, 0, _deadZone);
     }
     foreach (InputSetup.Button b in _scriptable.buttons)
     {
         AddButton(b, 0);
     }
 }
コード例 #11
0
 public void Read(Packet packet, InputSetup setup)
 {
     _queue.Dequeue(packet);
 }
コード例 #12
0
        public static void SetupDedicatedControllsForTheTestSubject()
        {
            var axisToAdd = new List <InputAxis>();

            if (!InputSetup.AxisDefined(KeyboardController.BODY_FORWARD_BACKWARDS))
            {
                axisToAdd.Add(new InputAxis()
                {
                    name           = KeyboardController.BODY_FORWARD_BACKWARDS,
                    type           = AxisType.KeyOrMouseButton,
                    positiveButton = "w",
                    negativeButton = "s",
                    gravity        = 10,
                    dead           = 0.001f,
                    sensitivity    = 3
                });
            }

            if (!InputSetup.AxisDefined(KeyboardController.BODY_TURN))
            {
                axisToAdd.Add(new InputAxis()
                {
                    name           = KeyboardController.BODY_TURN,
                    type           = AxisType.KeyOrMouseButton,
                    positiveButton = "d",
                    negativeButton = "a",
                    gravity        = 10,
                    dead           = 0.001f,
                    sensitivity    = 3
                });
            }

            if (!InputSetup.AxisDefined(KeyboardController.BODY_STRAFE))
            {
                axisToAdd.Add(new InputAxis()
                {
                    name           = KeyboardController.BODY_STRAFE,
                    type           = AxisType.KeyOrMouseButton,
                    positiveButton = "q",
                    negativeButton = "e",
                    gravity        = 10,
                    dead           = 0.001f,
                    sensitivity    = 3,
                });
            }


            if (!InputSetup.AxisDefined(KeyboardController.HEAD_UP_DOWN))
            {
                axisToAdd.Add(new InputAxis()
                {
                    name           = KeyboardController.HEAD_UP_DOWN,
                    type           = AxisType.KeyOrMouseButton,
                    positiveButton = "up",
                    negativeButton = "down",
                    gravity        = 100,
                    invert         = true,
                    dead           = 0.001f,
                    sensitivity    = 3
                });
            }

            if (!InputSetup.AxisDefined(KeyboardController.HEAD_TURN))
            {
                axisToAdd.Add(new InputAxis()
                {
                    name           = KeyboardController.HEAD_TURN,
                    type           = AxisType.KeyOrMouseButton,
                    positiveButton = "right",
                    negativeButton = "left",
                    gravity        = 100,
                    dead           = 0.001f,
                    sensitivity    = 3
                });
            }

            foreach (var axis in axisToAdd)
            {
                InputSetup.AddAxis(axis);
            }
        }
コード例 #13
0
        public IInputContext PrepareVersion(UpdateVersionContext update, ITargetQueue <Packet> outputQueue, InputSetup setup)
        {
            update.RuntimeConfig.Add(this, setup);
            update.AddDeploy(() =>
            {
                bool startOpenThread = false;
                lock (this)
                {
                    var last        = _inputThreadCurrentContext;
                    bool sameConfig = last != null && last.ContextSetup.Equals(setup);
                    bool sameDevice = last != null && last.ContextSetup.Input.Equals(setup.Input);
                    if (!sameConfig)
                    {
                        Core.LogInfo($"Change {_name}: {last?.ContextSetup} >> {setup}");
                    }

                    int version = update.Version;
                    var ver     = new ContextVersion <IInputContext, InputSetup, Packet>
                    {
                        Version      = version,
                        ContextSetup = setup,
                        OutputQueue  = outputQueue,
                    };

                    if (sameConfig)
                    {
                        ver.Context = last.Context.AddRef();

                        _inputThreadPendingContext?.Dispose();
                        _inputThreadPendingContext = ver;
                    }
                    else
                    {
                        if (sameDevice || last == null || _openThreadDenied)
                        {
                            _inputThreadPendingContext?.Dispose();
                            _inputThreadPendingContext = ver;

                            if (_inputThreadCurrentContext != null && _inputThreadCurrentContext.Context != null)
                            {
                                _inputThreadCurrentContext.Context.Instance.Interrupt();
                            }
                        }
                        else
                        {
                            _openThreadPendingContext?.Dispose();
                            _openThreadPendingContext = ver;

                            if (_openThreadRunningContext != null && _openThreadRunningContext.Context != null)
                            {
                                _openThreadRunningContext.Context.Instance.Interrupt();
                            }

                            if (!_openThreadIsRunning)
                            {
                                _openThreadIsRunning = true;
                                startOpenThread      = true;
                            }
                        }
                    }
                }

                if (!_inputThreadIsRunning)
                {
                    _inputThreadIsRunning = true;
                    _inputThread.Start();
                }
                if (startOpenThread)
                {
                    _openThread      = new Thread(() => OnOpenThread());
                    _openThread.Name = $"Streamer:{Name} input-open thread";
                    _openThread.Start();
                }
            });

            var last = _inputThreadCurrentContext;

            // same config and at least one time opened
            return((last != null && last.Context != null && last.Context.Instance.Config != null) ? last.Context.Instance : null);
        }
コード例 #14
0
 public void Read(Packet packet, InputSetup setup)
 {
     _audio.Read(packet);
 }