Exemple #1
0
    void ControllerMovement(ref Vector2 moveInput)
    {
        moveInput.x = XInput.GetLeftX();
        moveInput.y = 0f;

        MovePlayer(ref moveInput);
    }
Exemple #2
0
        protected override bool XStartProgram(XInput xargs, out XProgram xprogram)
        {
            bool bRes = true;

            xprogram = null;
            bRes     = xargs.XRead();
            if (bRes)
            {
                List <string> args = null;
                bRes = xargs.XReadStrings(out args);
                if (bRes)
                {
                    Process proc = new Process();
                    proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                    //proc.StartInfo.FileName = xargs.XFirst + ".bat";
                    proc.StartInfo.FileName        = "dotnet";
                    proc.StartInfo.UseShellExecute = false;
                    proc.StartInfo.CreateNoWindow  = false;
                    proc.StartInfo.Arguments       = xargs.XFirst + ".dll " + string.Join(" ", args);
                    bRes = proc.Start();
                    if (bRes)
                    {
                        CSProgram program = new CSProgram();
                        program.Process = proc;
                        xprogram        = program;
                    }
                }
            }
            return(bRes);
        }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     mainCamera = Camera.main;
     inputer = GameObject.FindWithTag ("INPUTER").GetComponent<XInput>();
     gameManager = GameObject.FindWithTag("GameController").GetComponent<GameManagement>();
     statsManager = gameObject.GetComponent<Stats> ();
 }
Exemple #4
0
 /// <summary>
 /// Called when the window closes, used to shutdown client systems.
 /// </summary>
 private void Window_Closed(object sender, EventArgs e)
 {
     if (VR != null)
     {
         VR.Stop();
         VR = null;
     }
     Sounds.Shutdown();
     if (RawGamePad != null)
     {
         RawGamePad.Dispose();
         RawGamePad = null;
     }
     if (LocalServer != null)
     {
         // TODO: ManualReset object?
         Object tlock = new Object();
         bool   done  = false;
         LocalServer.ShutDown(() => { lock (tlock) { done = true; } });
         bool b = false;
         while (!b)
         {
             Thread.Sleep(250);
             lock (tlock)
             {
                 b = done;
             }
         }
     }
     // TODO: Cleanup!
     OnClosed?.Invoke();
     Environment.Exit(0);
 }
Exemple #5
0
 private void Window_Closed(object sender, EventArgs e)
 {
     Sounds.StopAll();
     if (RawGamePad != null)
     {
         RawGamePad.Dispose();
         RawGamePad = null;
     }
     if (LocalServer != null)
     {
         Object tlock = new Object();
         bool   done  = false;
         LocalServer.ShutDown(() => { lock (tlock) { done = true; } });
         bool b = false;
         while (!b)
         {
             Thread.Sleep(250);
             lock (tlock)
             {
                 b = done;
             }
         }
     }
     // TODO: Cleanup!
     Environment.Exit(0);
 }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     actualPhase = Phases.ludus;
     mainCamera = Camera.main;
     inputer = GameObject.FindWithTag("INPUTER").GetComponent<XInput>();
     player = GameObject.FindWithTag ("Player");
 }
Exemple #7
0
 public void XInputEnable(bool enable)
 {
     lock (XInputLock)
     {
         XInput.XInputEnable(enable);
     }
 }
Exemple #8
0
 void Start()
 {
     startButt = GameObject.FindWithTag (tab_but[0]);
     startButt.renderer.material.color = Color.blue;
     resolutions = Screen.resolutions;
     inputer = GameObject.FindWithTag ("INPUTER").GetComponent<XInput>();
 }
Exemple #9
0
        protected override bool XCreateInput(out XInput xinput, out string output)
        {
            bool bRes = true;

            xinput = new PipeInput(out output);
            return(bRes);
        }
 public static IObservable <NamedControllerId> ActiveJoystick()
 {
     return(UnityObservable.CreateUpdate <NamedControllerId>(observer => {
         var xinputJoystickId = XInput.AnyJoystick();
         var unityJoystickId = UnityInputMaps.AnyJoystick();
         if (xinputJoystickId.HasValue)
         {
             var controllerId = new ControllerId.XInput(xinputJoystickId.Value);
             observer.OnNext(new NamedControllerId(controllerId, "XInput controller"));
         }
         else if (unityJoystickId.HasValue)
         {
             var controllerId = new ControllerId.Unity(unityJoystickId.Value);
             var controllerName = UnityEngine.Input.GetJoystickNames()[controllerId.Id];
             observer.OnNext(new NamedControllerId(controllerId, controllerName));
         }
     })
            // XInput takes presedence over unity input because we know how to handle it better.
            // So if we detect an XInput device we ignore the Unity device(s) detected during the
            // same window.
            .Window(TimeSpan.FromSeconds(0.8f), Scheduler.TaskPool)
            .SelectMany(inputSources => {
         return inputSources.Scan((selectedInputSource, inputSource) => {
             if (selectedInputSource.ControllerId is ControllerId.XInput)
             {
                 return selectedInputSource;
             }
             return inputSource;
         }).TakeLast(1);
     })
            .ObserveOn(UnityThreadScheduler.MainThread));;
 }
        public override void Update(GameTime gameTime)
        {
            menuComponent.Update(gameTime);

            if (XInput.CheckKeyReleased(Keys.Space) || XInput.CheckKeyReleased(Keys.Enter) ||
                (menuComponent.MouseOver && XInput.CheckMouseReleased(MouseButtons.Left)))
            {
                if (menuComponent.SelectedIndex == 0)
                {
                    if (isSoundEnabled)
                    {
                        isSoundEnabled = false;
                    }
                    else if (!isSoundEnabled)
                    {
                        isSoundEnabled = true;
                    }
                }
                else if (menuComponent.SelectedIndex == 1)
                {
                    manager.ChangeState((MainMenuState)GameRef.StartMenuState);
                }
            }
            base.Update(gameTime);
        }
Exemple #12
0
        protected override bool XIsProgram(XInput xinput)
        {
            string dir  = Directory.GetCurrentDirectory();
            bool   bRes = File.Exists(xinput.XFirst + ".bat");

            return(bRes);
        }
    void HandleInputSelectLevel()
    {
        if (m_moveTimer != m_timeBetweenPoints)
        {
            return;
        }

        bool inputSelect = false;

        inputSelect = Input.GetKey(KeyCode.Space);
        if (!Singleton.GameVarsManager.m_gameVars.m_keyboardControl)
        {
            XInput.XInputState state;
            XInput.XInputGetState(0, out state);
            inputSelect |= state.Gamepad.IsButtonDown(XInput.XInputButtons.A);
        }

        if (inputSelect)
        {
            SaveGame.GetData().worldMapWorldIndex = m_worldIndex;
            SaveGame.GetData().worldMapPointIndex = m_pointIndex;

            // Auto Save
            SaveGame.Save();

            m_canvas.SetActive(false);
            Camera.main.GetComponent <CameraIntoBook>().StartCameraTransition(GetCurrentLevelIndex());
        }
    }
        public override void Update(GameTime gameTime)
        {
            menuComponent.Update(gameTime);

            if (XInput.CheckKeyReleased(Keys.Space) || XInput.CheckKeyReleased(Keys.Enter) ||
                (menuComponent.MouseOver && XInput.CheckMouseReleased(MouseButtons.Left)))
            {
                if (menuComponent.SelectedIndex == 0)
                {
                    difficulty = "EASY";
                    manager.ChangeState((PlayState)GameRef.StartPlayState);
                }
                else if (menuComponent.SelectedIndex == 1)
                {
                    difficulty = "MEDIUM";
                    manager.ChangeState((PlayState)GameRef.StartPlayState);
                }
                else if (menuComponent.SelectedIndex == 2)
                {
                    difficulty = "HARD";
                    manager.ChangeState((PlayState)GameRef.StartPlayState);
                }
                else if (menuComponent.SelectedIndex == 3)
                {
                    manager.ChangeState((MainMenuState)GameRef.StartMenuState);
                }
            }
            base.Update(gameTime);
        }
Exemple #15
0
 private void XInputInputChanged(object sender, DeviceInputChangedEventArgs e)
 {
     if (!xOutputManager.XOutputDevice.Report(controllerCount, XInput.GetValues()))
     {
         Stop();
     }
 }
        public void Update(GameTime gameTime)
        {
            uiManager.KeyBoardInput();

            //if tower is being built, check mouse input
            if (XInput.CheckMouseReleased(MouseButtons.Left))
            {
                Point mousePoint = XInput.MouseState.Position;
                uiManager.MouseInput(MouseButtons.Left, mousePoint);
            }
            uiManager.Update(gameTime);
            towerManager.Update(gameTime);
            enemyManager.Update(gameTime);

            if (!waveManager.waitingToStartWave(gameTime)) //if waiting time between waves is over
            {
                if (!waveManager.AreEnemiesLeft())         //and there arent any more enemies left to spawn this wave
                {
                    waveManager.StartWave();               //start next wave
                }
                else
                {
                    waveManager.Spawn(gameTime);
                }
            }

            if (gameHealth <= 0)
            {
                GameOver('l');
            }
        }
Exemple #17
0
        /// <summary>
        /// Observes the gamepad for status changes.
        /// </summary>
        private void ObserveGamepad()
        {
            uint lastPacketNumber = 0;

            XInput.State     state     = new XInput.State();
            XInput.KeyStroke keystroke = new XInput.KeyStroke();
            while (!this.StopObserving)
            {
                XInput.Error result = XInput.GetState((XInput.UserIndex) this.UserIndex, out state);
                if (result == XInput.Error.Success && state.packetNumber > lastPacketNumber)
                {
                    lastPacketNumber = state.packetNumber;
                    this.SetStateFromXInputState(state);
                    this.RaiseStateChanged();
                }

                result = XInput.GetKeystroke((XInput.UserIndex) this.UserIndex, out keystroke);
                if (result == XInput.Error.Success)
                {
                    if (keystroke.flags == XInput.KeyStrokeFlags.KeyUp)
                    {
                        this.RaiseKeyUp((KeyEventArgs.KeyCode)keystroke.virtualKey);
                    }

                    if (keystroke.flags == XInput.KeyStrokeFlags.KeyDown)
                    {
                        this.RaiseKeyDown((KeyEventArgs.KeyCode)keystroke.virtualKey);
                    }
                }

                Thread.Sleep(2);
            }
        }
Exemple #18
0
    // Use this for initialization
    void Start()
    {
        Ctr = GameObject.Find ("Ludus_Control");
        inputer = GameObject.FindWithTag ("INPUTER").GetComponent<XInput>();

        control = false;
    }
Exemple #19
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            XInputState state = new XInputState();

            XInput.XInputGetState(0, ref state);
            List <XBoxControllerInput> currentInputs = getCurrentInputs(state);

            btn_a.Visible = currentInputs.Contains(XBoxControllerInput.A);
            btn_b.Visible = currentInputs.Contains(XBoxControllerInput.B);
            btn_x.Visible = currentInputs.Contains(XBoxControllerInput.X);
            btn_y.Visible = currentInputs.Contains(XBoxControllerInput.Y);

            btn_R.Visible = currentInputs.Contains(XBoxControllerInput.RShoulder);
            btn_L.Visible = currentInputs.Contains(XBoxControllerInput.LShoulder);

            btn_Ddown.Visible  = currentInputs.Contains(XBoxControllerInput.DDown);
            btn_Dup.Visible    = currentInputs.Contains(XBoxControllerInput.DUp);
            btn_Dleft.Visible  = currentInputs.Contains(XBoxControllerInput.DLeft);
            btn_Dright.Visible = currentInputs.Contains(XBoxControllerInput.DRight);

            btn_start.Visible      = currentInputs.Contains(XBoxControllerInput.Start);
            btn_back.Visible       = currentInputs.Contains(XBoxControllerInput.Back);
            stick.BackgroundImage  = currentInputs.Contains(XBoxControllerInput.LStick) ? Properties.Resources.stick_2 : Properties.Resources.stick_1;
            stick2.BackgroundImage = currentInputs.Contains(XBoxControllerInput.RStick) ? Properties.Resources.stick_2 : Properties.Resources.stick_1;

            btnR_trig.Visible = currentInputs.Contains(XBoxControllerInput.RTrigger);
            btnL_trig.Visible = currentInputs.Contains(XBoxControllerInput.LTrigger);

            stick.Left  = StickOriginX + STICK_DISTANCE * state.sThumbLX / 32768;
            stick.Top   = StickOriginY - STICK_DISTANCE * state.sThumbLY / 32768;
            stick2.Left = StickOriginX2 + STICK_DISTANCE * state.sThumbRX / 32768;
            stick2.Top  = StickOriginY2 - STICK_DISTANCE * state.sThumbRY / 32768;
        }
Exemple #20
0
 void Start()
 {
     startButt = GameObject.FindWithTag (tab_but[0]);
     startButt.renderer.material.color = Color.blue;
     selected = 0;
     Main_cam = GameObject.FindWithTag("MainCamera");
     inputer = GameObject.FindWithTag ("INPUTER").GetComponent<XInput>();
 }
Exemple #21
0
    // Use this for initialization
    void Start()
    {
        option_butt = GameObject.FindWithTag (tab_opt[1]);
        nombreObject = GameObject.FindWithTag ("Volume");
        option_butt.renderer.material.color = Color.blue;

        inputer = GameObject.FindWithTag ("INPUTER").GetComponent<XInput>();
    }
Exemple #22
0
        public static DeviceEffectItem[] GetDeviceEffects(Joystick device)
        {
            var items = new List <DeviceEffectItem>();

            if (device == null)
            {
                return(items.ToArray());
            }
            // Check if device supports force feedback.
            var forceFeedback = device.Capabilities.Flags.HasFlag(DeviceFlags.ForceFeedback);

            if (!forceFeedback)
            {
                return(items.ToArray());
            }
            lock (XInput.XInputLock)
            {
                // Unload xinput.
                var isLoaded = XInput.IsLoaded;
                if (isLoaded)
                {
                    XInput.FreeLibrary();
                }
                // Must reaquire device in exclusive mode to get effects.
                device.Unacquire();
                device.SetCooperativeLevel(MainForm.Current.Handle, CooperativeLevel.Foreground | CooperativeLevel.Exclusive);
                IList <EffectInfo> effects = new List <EffectInfo>();
                try
                {
                    device.Acquire();
                    effects = device.GetEffects(EffectType.All);
                }
                catch (Exception)
                {
                }
                foreach (var eff in effects)
                {
                    items.Add(new DeviceEffectItem()
                    {
                        Name              = eff.Name,
                        StaticParameters  = eff.StaticParameters,
                        DynamicParameters = eff.DynamicParameters,
                    });
                }
                // Reaquire device in non exclusive mode.
                device.Unacquire();
                device.SetCooperativeLevel(MainForm.Current.Handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive);
                // If XInput was loaded then...
                if (isLoaded)
                {
                    Exception error;
                    XInput.ReLoadLibrary(XInput.LibraryName, out error);
                }
            }
            return(items.ToArray());
        }
Exemple #23
0
    #pragma warning restore 0649


    protected override void InputUpdate()
    {
        XInput.Direction direction = XInput.GetDPadDirection(playerIndex);

        foreach (DPadDirection dPadDirection in dPadDirections)
        {
            // That way, we only enable the current direction's image
            dPadDirection.EnableImage(dPadDirection.IsConcerned(direction));
        }
    }
        public override void Update(GameTime gameTime)
        {
            elapsed += gameTime.ElapsedGameTime;

            if (XInput.CheckKeyReleased(Keys.Space) || XInput.CheckKeyReleased(Keys.Enter) || XInput.CheckMouseReleased(MouseButtons.Left))
            {
                manager.ChangeState((MainMenuState)GameRef.StartMenuState);
            }
            base.Update(gameTime);
        }
Exemple #25
0
 // Update is called once per frame
 void LateUpdate()
 {
     if (!XInput.GetConnected(0))
     {
         if (Input.GetKeyDown(KeyCode.Space))
         {
             addJump();
         }
     }
 }
Exemple #26
0
    private const float maxFillAmount = 0.88f; // Because the sprite shouldn't be completely filled


    protected override void InputUpdate()
    {
        float triggerValue = XInput.GetTriggerValue(trigger, playerIndex);

        if (triggerValue == 1f) // Set a vibration when we hit the maximum trigger value
        {
            XInput.SetVibration(trigger, 0.5f, 0.5f, playerIndex);
        }

        fillImage.fillAmount = triggerValue * maxFillAmount;
    }
Exemple #27
0
 void OnEnable()
 {
     if (XInput.GetConnected())
     {
         img.texture = XboxTex;
     }
     else
     {
         img.texture = KBTex;
     }
 }
Exemple #28
0
 // Update is called once per frame
 void Update()
 {
     if (XInput.GetConnected())
     {
         img.texture = XboxTex;
     }
     else
     {
         img.texture = KBTex;
     }
 }
Exemple #29
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            XInput.GetState(0, out State s);
            if (s.PacketNumber != _prevPacketNum)
            {
                _prevPacketNum = s.PacketNumber;

                numericUpDown1.Value = Math.Clamp((decimal)s.Gamepad.LeftThumbY / 32767, -1, 1);
                numericUpDown2.Value = Math.Clamp((decimal)s.Gamepad.LeftThumbX / 32767, -1, 1);
                numericUpDown3.Value = Math.Clamp((decimal)s.Gamepad.RightThumbX / 32767, -1, 1);
            }
        }
Exemple #30
0
    // Use this for initialization
    void Start()
    {
        player       = GameObject.FindGameObjectWithTag("Player");
        playerHealth = player.GetComponent <PlayerHeatlh>();
        controller   = player.GetComponent <XInput>();

        enemyHealth = GetComponent <EnemyHealth>();
        Debug.Log(" player health: " + playerHealth.currentHealth);


        animator = GetComponent <Animator>();
    }
Exemple #31
0
    void Awake()
    {
        if (Instance != null)
        {
            Debug.LogError(string.Format("Only one XInput Script should exist in the scene. Destroying this one, attached to GameObject \"{0}\"", gameObject.name));
            Destroy(this);
            return;
        }

        Instance = this;

        InitControllers();
    }
Exemple #32
0
    void ControllerInputs()
    {
        ControllerMovement(ref move_input);
        if (XInput.GetKeyPressed(0, (int)Buttons.A))
        {
            PlayerJump();
        }

        if (XInput.GetKeyPressed(0, (int)Buttons.RTrig))
        {
            PlayerDash();
        }
    }
 public void Update()
 {
     fred[0]      = XInput.GetButton(deviceId, XInput.Button.A);
     fred[1]      = XInput.GetButton(deviceId, XInput.Button.B);
     fred[2]      = XInput.GetButton(deviceId, XInput.Button.Y);
     fred[3]      = XInput.GetButton(deviceId, XInput.Button.X);
     fred[4]      = XInput.GetButton(deviceId, XInput.Button.LB);
     startPressed = XInput.GetButtonDown(deviceId, XInput.Button.Start);
     starPressed  = XInput.GetButtonDown(deviceId, XInput.Button.Back);
     strumPressed = XInput.GetButtonDown(deviceId, XInput.Button.DPadDown) | XInput.GetButtonDown(deviceId, XInput.Button.DPadUp);
     tilt         = XInput.GetAxis(deviceId, XInput.Axis.RY);
     whammy       = XInput.GetAxis(deviceId, XInput.Axis.RX);
 }
Exemple #34
0
        private void Form1_Load(object sender, EventArgs e)
        {
            XInput.GetCapabilities(0, DeviceQueryType.Gamepad, out Capabilities c);
            if (c.Type == DeviceType.Gamepad)
            {
                label12.Text   = "Controller Connected";
                timer1.Enabled = true;

                numericUpDown1.Enabled = false;
                numericUpDown2.Enabled = false;
                numericUpDown3.Enabled = false;
            }
        }
Exemple #35
0
        private void controllers_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (mon != null)
            {
                mon.Dispose();
            }
            var controller = controllers.SelectedItem as Controller;

            mon = new ControllerMonitor(controller);
            mon.OnStateChanged += Mon_OnStateChanged;
            XInput.BatteryInformation xbi = default;
            XInput.XInputGetBatteryInformation(controller.Index, XInput.BatteryDevType.Gamepad, ref xbi);
            label4.Text = $"Battery: {xbi.BatteryType} {xbi.BatteryLevel}";
        }
    Vector2 GetInputVector()
    {
        Vector2 input = Vector2.zero;

        input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        if (!Singleton.GameVarsManager.m_gameVars.m_keyboardControl)
        {
            XInput.XInputState state;
            XInput.XInputGetState(0, out state);
            input = new Vector2(state.Gamepad.LeftThumbX / 32768.0f, state.Gamepad.LeftThumbY / 32768.0f);
        }
        input.Normalize();
        return(input);
    }
 public XConnection(string ipAddress, int port, string userName, string password)
 {
     var settings = new XSettings(ipAddress, port, userName, password);
     var client = new XClient(settings);
     Client = client;
     XHelpers.Settings = settings;
     AudioLibrary = new XAudioLibrary(client);
     VideoLibrary = new XVideoLibrary(client);
     AudioPlayer = new XAudioPlayer(client);
     VirtualRemote = new XVirtualRemote(settings);
     System = new XSystem(client);
     JsonRpc = new XJsonRpc(client);
     Input = new XInput(client);
     // new for Eden
     //Player = new XPlayer(client);
 }
Exemple #38
0
    // Use this for initialization
    void Start()
    {
        gameManager = GameObject.FindWithTag("GameController").GetComponent<GameManagement>();
        // Commande 360
        inputer = GameObject.FindWithTag ("INPUTER").GetComponent<XInput>();
        //Recuperation objet
        //Cam
        //Main_cam = GameObject.FindWithTag ("MainCamera");
        Main_cam = GameObject.FindWithTag ("Player");

        //Capsule
        Competence = GameObject.FindWithTag ("Caps - Competence");
        Forge = GameObject.FindWithTag ("Caps - Forge");
        Entraineur = GameObject.FindWithTag ("Caps - Entraineur");
        Personnage = GameObject.FindWithTag ("Caps - Personnage");

        //Menu
        m_Competence = GameObject.FindWithTag ("Menu - Competence");
        m_Forge = GameObject.FindWithTag ("Menu - Forge");
        m_Entraineur = GameObject.FindWithTag ("Menu - Entraineur");
        m_Personnage = GameObject.FindWithTag ("Menu - Personnage");
    }
Exemple #39
0
 // Use this for initialization
 void Start()
 {
     inputer = GameObject.FindWithTag ("INPUTER").GetComponent<XInput>();
     player = GameObject.FindGameObjectWithTag("Player").GetComponent<Stats>();
     Initialize_shop ();
 }
Exemple #40
0
    void Awake()
    {
        instance = this;
        buttondown = new bool[2];
        buttondown[0] = false;
        buttondown[1] = false;

        vibePlayer = new int[2];
        vibePlayer[0] = 0;
        vibePlayer[1] = 0;
    }
Exemple #41
0
 // Use this for initialization
 void Start()
 {
     enAttack = false;
     inputer = GameObject.FindWithTag ("INPUTER").GetComponent<XInput>();
     gameManager = GameObject.FindWithTag("GameController").GetComponent<GameManagement>();
 }