Example #1
0
    public SimulatedInput popSimulatedInput()
    {
        SimulatedInput head = simulatedInputs[0];

        removeSimulatedInput(0);
        return(head);
    }
Example #2
0
    IEnumerator computeButton(SimulatedInput btn)
    {
        InputManager.inputs[btn.name] = 1f;
        yield return(new WaitForSeconds(btn.duration));

        InputManager.inputs.Remove(btn.name);
    }
Example #3
0
    IEnumerator computeAxisRaw(SimulatedInput btn)
    {
        InputManager.inputs[btn.name] = btn.valueX;
        yield return(new WaitForSeconds(btn.duration));

        InputManager.inputs.Remove(btn.name);
    }
Example #4
0
 public void moveSimulatedInputDown(int index)
 {
     if (index < simulatedInputs.Count - 1)
     {
         SimulatedInput value = simulatedInputs[index];
         simulatedInputs.RemoveAt(index);
         simulatedInputs.Insert(index + 1, value);
     }
 }
Example #5
0
 public void moveSimulatedInputUp(int index)
 {
     if (index > 0)
     {
         SimulatedInput value = simulatedInputs[index];
         simulatedInputs.RemoveAt(index);
         simulatedInputs.Insert(index - 1, value);
     }
 }
Example #6
0
    void compute()
    {
        if (waiting)
        {
            return;
        }

        if (simulatedInputs.Count <= 0)
        {
            //Debug.Log("Input Scripter: Done!");
            enabled = false;
            return;
        }

        SimulatedInput nextInput = popSimulatedInput();

        if (nextInput.option == SimulatedInputOption.Button)
        {
            StartCoroutine("computeButton", nextInput);
        }

        if (nextInput.option == SimulatedInputOption.ButtonDown)
        {
            computeButtonDown(nextInput.name);
        }

        if (nextInput.option == SimulatedInputOption.AxisRaw)
        {
            StartCoroutine("computeAxisRaw", nextInput);
        }

        if (nextInput.option == SimulatedInputOption.Axis)
        {
            StartCoroutine("computeAxis", nextInput);
        }

        if (nextInput.option == SimulatedInputOption.MousePos)
        {
            computeMousePos(nextInput);
        }

        if (nextInput.option == SimulatedInputOption.Wait)
        {
            waiting = true;
            Invoke("resumeComputation", nextInput.duration);
        }
    }
Example #7
0
    IEnumerator computeAxis(SimulatedInput btn)
    {
        float waitAfterDelay = Mathf.Abs(btn.duration - btn.delay);
        float velocity       = 1f / btn.delay;
        float timer          = 0.0f;

        InputManager.inputs[btn.name] = btn.valueX;

        while (timer < btn.delay)
        {
            timer += Time.deltaTime;
            InputManager.inputs[btn.name] = (timer * velocity) * btn.valueX;
            yield return(null);
        }

        yield return(new WaitForSeconds(waitAfterDelay));

        InputManager.inputs.Remove(btn.name);
    }
Example #8
0
 void computeMousePos(SimulatedInput btn)
 {
     InputManager.simulatedMousePos = new Vector3(btn.valueX, btn.valueY, 0f);
 }
Example #9
0
        // used for basic mouse and keyboard actions (fixed mappings)
        protected void UpdateMouseMode()
        {
            SimulatedInput simInput = new SimulatedInput();

            foreach (KeyValuePair <string, float> input in Values)
            {
                switch (input.Key)
                {
                    #region Pro Controller Inputs
                case Inputs.ProController.A: simInput.leftMouseBtn |= input.Value > 0f; break;

                case Inputs.ProController.B: simInput.rightMouseBtn |= input.Value > 0f; break;

                case Inputs.ProController.X: simInput.delKey |= input.Value > 0f; break;

                case Inputs.ProController.Y: simInput.escKey |= input.Value > 0f; break;

                case Inputs.ProController.L: simInput.altKey |= input.Value > 0f; break;

                case Inputs.ProController.R: simInput.tabKey |= input.Value > 0f; break;

                case Inputs.ProController.ZL: simInput.ctrlKey |= input.Value > 0f; break;

                case Inputs.ProController.ZR: simInput.shiftKey |= input.Value > 0f; break;

                case Inputs.ProController.UP: simInput.upKey |= input.Value > 0f; break;

                case Inputs.ProController.DOWN: simInput.downKey |= input.Value > 0f; break;

                case Inputs.ProController.LEFT: simInput.leftKey |= input.Value > 0f; break;

                case Inputs.ProController.RIGHT: simInput.rightKey |= input.Value > 0f; break;

                case Inputs.ProController.LUP: simInput.moveMouseY += 6 * input.Value; break;

                case Inputs.ProController.LDOWN: simInput.moveMouseY -= 6 * input.Value; break;

                case Inputs.ProController.LLEFT: simInput.moveMouseX -= 6 * input.Value; break;

                case Inputs.ProController.LRIGHT: simInput.moveMouseX += 6 * input.Value; break;

                case Inputs.ProController.LS: simInput.leftMouseBtn |= input.Value > 0f; break;

                case Inputs.ProController.RUP: simInput.upKey |= input.Value > 0.1f; break;

                case Inputs.ProController.RDOWN: simInput.downKey |= input.Value > 0.1f; break;

                case Inputs.ProController.RLEFT: simInput.leftKey |= input.Value > 0.1f; break;

                case Inputs.ProController.RRIGHT: simInput.rightKey |= input.Value > 0.1f; break;

                case Inputs.ProController.RS: simInput.rightMouseBtn |= input.Value > 0f; break;

                case Inputs.ProController.START: simInput.enterKey |= input.Value > 0f; break;

                case Inputs.ProController.SELECT: simInput.desktop |= input.Value > 0f; break;

                case Inputs.ProController.HOME: MouseModeCheck(input.Value > 0f); break;
                    #endregion

                    #region Wiimote Inputs
                case Inputs.Wiimote.A: simInput.leftMouseBtn |= input.Value > 0f; break;

                case Inputs.Wiimote.B: simInput.rightMouseBtn |= input.Value > 0f; break;

                case Inputs.Wiimote.ONE: simInput.altKey |= input.Value > 0f; break;

                case Inputs.Wiimote.TWO: simInput.tabKey |= input.Value > 0f; break;

                case Inputs.Wiimote.UP: simInput.upKey |= input.Value > 0f; break;

                case Inputs.Wiimote.DOWN: simInput.downKey |= input.Value > 0f; break;

                case Inputs.Wiimote.LEFT: simInput.leftKey |= input.Value > 0f; break;

                case Inputs.Wiimote.RIGHT: simInput.rightKey |= input.Value > 0f; break;

                case Inputs.Wiimote.PLUS: simInput.ctrlKey |= input.Value > 0f; break;

                case Inputs.Wiimote.MINUS: simInput.shiftKey |= input.Value > 0f; break;

                case Inputs.Wiimote.HOME: MouseModeCheck(input.Value > 0f); break;
                    #endregion

                    #region Nunchuk Inputs
                case Inputs.Nunchuk.C: simInput.ctrlKey |= input.Value > 0f; break;

                case Inputs.Nunchuk.Z: simInput.shiftKey |= input.Value > 0f; break;

                case Inputs.Nunchuk.UP: simInput.moveMouseY += 6 * input.Value; break;

                case Inputs.Nunchuk.DOWN: simInput.moveMouseY -= 6 * input.Value; break;

                case Inputs.Nunchuk.LEFT: simInput.moveMouseX -= 6 * input.Value; break;

                case Inputs.Nunchuk.RIGHT: simInput.moveMouseX += 6 * input.Value; break;
                    #endregion

                    #region Classic Controller Inputs
                case Inputs.ClassicController.A: simInput.leftMouseBtn |= input.Value > 0f; break;

                case Inputs.ClassicController.B: simInput.rightMouseBtn |= input.Value > 0f; break;

                case Inputs.ClassicController.X: break;

                case Inputs.ClassicController.Y: break;

                case Inputs.ClassicController.L: simInput.altKey |= input.Value > 0f; break;

                case Inputs.ClassicController.R: simInput.tabKey |= input.Value > 0f; break;

                case Inputs.ClassicController.ZL: simInput.ctrlKey |= input.Value > 0f; break;

                case Inputs.ClassicController.ZR: simInput.shiftKey |= input.Value > 0f; break;

                case Inputs.ClassicController.UP: simInput.upKey |= input.Value > 0f; break;

                case Inputs.ClassicController.DOWN: simInput.downKey |= input.Value > 0f; break;

                case Inputs.ClassicController.LEFT: simInput.leftKey |= input.Value > 0f; break;

                case Inputs.ClassicController.RIGHT: simInput.rightKey |= input.Value > 0f; break;

                case Inputs.ClassicController.LUP: simInput.moveMouseY += 6 * input.Value; break;

                case Inputs.ClassicController.LDOWN: simInput.moveMouseY -= 6 * input.Value; break;

                case Inputs.ClassicController.LLEFT: simInput.moveMouseX -= 6 * input.Value; break;

                case Inputs.ClassicController.LRIGHT: simInput.moveMouseX += 6 * input.Value; break;

                case Inputs.ClassicController.RUP: simInput.upKey |= input.Value > 0.1f; break;

                case Inputs.ClassicController.RDOWN: simInput.downKey |= input.Value > 0.1f; break;

                case Inputs.ClassicController.RLEFT: simInput.leftKey |= input.Value > 0.1f; break;

                case Inputs.ClassicController.RRIGHT: simInput.rightKey |= input.Value > 0.1f; break;

                case Inputs.ClassicController.START: break;

                case Inputs.ClassicController.SELECT: break;

                case Inputs.ClassicController.HOME: MouseModeCheck(input.Value > 0f); break;     // might need some sort of delay
                    #endregion

                    #region Classic Controller Pro Inputs
                case Inputs.ClassicControllerPro.A: simInput.leftMouseBtn |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.B: simInput.rightMouseBtn |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.X: break;

                case Inputs.ClassicControllerPro.Y: break;

                case Inputs.ClassicControllerPro.L: simInput.altKey |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.R: simInput.tabKey |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.ZL: simInput.ctrlKey |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.ZR: simInput.shiftKey |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.UP: simInput.upKey |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.DOWN: simInput.downKey |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.LEFT: simInput.leftKey |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.RIGHT: simInput.rightKey |= input.Value > 0f; break;

                case Inputs.ClassicControllerPro.LUP: simInput.moveMouseY += 6 * input.Value; break;

                case Inputs.ClassicControllerPro.LDOWN: simInput.moveMouseY -= 6 * input.Value; break;

                case Inputs.ClassicControllerPro.LLEFT: simInput.moveMouseX -= 6 * input.Value; break;

                case Inputs.ClassicControllerPro.LRIGHT: simInput.moveMouseX += 6 * input.Value; break;

                case Inputs.ClassicControllerPro.RUP: simInput.upKey |= input.Value > 0.1f; break;

                case Inputs.ClassicControllerPro.RDOWN: simInput.downKey |= input.Value > 0.1f; break;

                case Inputs.ClassicControllerPro.RLEFT: simInput.leftKey |= input.Value > 0.1f; break;

                case Inputs.ClassicControllerPro.RRIGHT: simInput.rightKey |= input.Value > 0.1f; break;

                case Inputs.ClassicControllerPro.START: break;

                case Inputs.ClassicControllerPro.SELECT: break;

                case Inputs.ClassicControllerPro.HOME: MouseModeCheck(input.Value > 0f); break;     // might need some sort of delay
                    #endregion
                }
            }

            #region Apply input
            if (simInput.desktop)
            {
                ShowDesktop();
            }

            // Mouse
            _inputSim.Mouse.MoveMouseBy((int)simInput.moveMouseX, (int)simInput.moveMouseY * -1);

            if (simInput.leftMouseBtn && !_lastInput.leftMouseBtn)
            {
                _inputSim.Mouse.LeftButtonDown();
            }
            else if (!simInput.leftMouseBtn && _lastInput.leftMouseBtn)
            {
                _inputSim.Mouse.LeftButtonUp();
            }

            if (simInput.rightMouseBtn && !_lastInput.rightMouseBtn)
            {
                _inputSim.Mouse.RightButtonDown();
            }
            else if (!simInput.rightMouseBtn && _lastInput.rightMouseBtn)
            {
                _inputSim.Mouse.RightButtonUp();
            }

            // Keyboard
            if (simInput.escKey && !_lastInput.escKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.ESCAPE);
            }
            else if (!simInput.escKey && _lastInput.escKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.ESCAPE);
            }

            if (simInput.altKey && !_lastInput.altKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.MENU);
            }
            else if (!simInput.altKey && _lastInput.altKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.MENU);
            }

            if (simInput.tabKey && !_lastInput.tabKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.TAB);
            }
            else if (!simInput.tabKey && _lastInput.tabKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.TAB);
            }

            if (simInput.ctrlKey && !_lastInput.ctrlKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.CONTROL);
            }
            else if (!simInput.ctrlKey && _lastInput.ctrlKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.CONTROL);
            }

            if (simInput.shiftKey && !_lastInput.shiftKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.SHIFT);
            }
            else if (!simInput.shiftKey && _lastInput.shiftKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.SHIFT);
            }

            if (simInput.enterKey && !_lastInput.enterKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.RETURN);
            }
            else if (!simInput.enterKey && _lastInput.enterKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.RETURN);
            }

            if (simInput.delKey && !_lastInput.delKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.DELETE);
            }
            else if (!simInput.delKey && _lastInput.delKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.DELETE);
            }

            if (simInput.upKey && !_lastInput.upKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.UP);
            }
            else if (!simInput.upKey && _lastInput.upKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.UP);
            }

            if (simInput.downKey && !_lastInput.downKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.DOWN);
            }
            else if (!simInput.downKey && _lastInput.downKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.DOWN);
            }

            if (simInput.leftKey && !_lastInput.leftKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.LEFT);
            }
            else if (!simInput.leftKey && _lastInput.leftKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.LEFT);
            }

            if (simInput.rightKey && !_lastInput.rightKey)
            {
                _inputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.RIGHT);
            }
            else if (!simInput.rightKey && _lastInput.rightKey)
            {
                _inputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.RIGHT);
            }
            #endregion

            _lastInput = simInput;
        }