private InputCore GetInputHandler()
    {
        inputDelay = 0.0f;
        InputCore c = gameObject.AddComponent <InputCore>();

        c.SetController(PD.controller, PD.GetKeyBindings());
        return(c);
    }
Exemple #2
0
        public void Initialize(PadTieForm form, InputCore core, Controller cc, int padNum)
        {
            mainForm   = form;
            this.core  = core;
            controller = cc;
            padNumber  = padNum;

            padView.SelectedItemChanged += ControllerClick;

            deviceName.Text         = cc.Device.Name;
            deviceGUID.Text         = cc.Device.ProductGUID.ToUpper();
            deviceInstanceGUID.Text = cc.Device.InstanceGUID.ToUpper();
            deviceVendorID.Text     = "0x" + cc.Device.VendorID.ToString("X4");
            deviceProductID.Text    = "0x" + cc.Device.ProductID.ToString("X4");

            UpdateDeviceInfo();

            deviceButtons.Text = string.Format("{0} buttons, {1} axes, {2} hats, force feedback: {3}",
                                               cc.Device.ButtonCount.ToString(),
                                               (cc.Device.AxisCount - cc.Device.HatCount).ToString(),
                                               cc.Device.HatCount.ToString(),
                                               cc.Device.ForceFeedback ? "yes" : "no");

            cc.Virtual.AxisAnalogReceived    += Analog;
            cc.Virtual.ButtonActiveReceived  += Active;
            cc.Virtual.ButtonPressReceived   += Press;
            cc.Virtual.ButtonReleaseReceived += Release;

            actionTree.ExpandAll();
            currentMappings.Nodes.Clear();

            foreach (var b in VirtualController.ButtonList)
            {
                SetupButton(b);
            }

            SetupAxisGesture(AxisGesture.LeftXNeg);
            SetupAxisGesture(AxisGesture.LeftXPos);
            SetupAxisGesture(AxisGesture.LeftYNeg);
            SetupAxisGesture(AxisGesture.LeftYPos);
            SetupAxisGesture(AxisGesture.RightXNeg);
            SetupAxisGesture(AxisGesture.RightXPos);
            SetupAxisGesture(AxisGesture.RightYNeg);
            SetupAxisGesture(AxisGesture.RightYPos);
            SetupAxisGesture(AxisGesture.DigitalXNeg);
            SetupAxisGesture(AxisGesture.DigitalXPos);
            SetupAxisGesture(AxisGesture.DigitalYNeg);
            SetupAxisGesture(AxisGesture.DigitalYPos);
            SetupAxisGesture(AxisGesture.TriggerNeg);
            SetupAxisGesture(AxisGesture.TriggerPos);

            currentMappings.ExpandAll();
            RefreshDeviceMappings();
        }
Exemple #3
0
        public ActionResult Index(InputEntity inputEntity)
        {
            var inputRequest = InputCore.Tratar(inputEntity);

            if (inputRequest.IsError)
            {
                ModelState.AddModelError("error", inputRequest.Message);
                return(View(new VariavelDiscretaContainerEntity()));
            }

            return(View(new VariavelDiscretaApp().Build(inputRequest.Content)));
        }
    public void Start()
    {
        StateControllerInit(false);

        playeractor = CreateActor(PD.GetPlayerSpritePath(PD.p1Char), new Vector3(-5.15f, 1.0f));
        PD.GetNextOpponent();
        opponentactor = CreateActor(PD.GetPlayerSpritePath(PD.p2Char), new Vector3(5.15f, 1.0f), true);
        skipMenuIsUp  = false;

        XmlNodeList dialogs = GetXMLHead("/" + playeractor.GetPath(PD.p1Char == PersistData.C.FuckingBalloon), "dialogs").SelectNodes("dialog");
        XmlNode     dialog  = dialogs[PD.GetPuzzleLevel()];

        dialogArr = dialog.SelectNodes("line");

        rawInput = GetInputHandler();

        dialogueBox = gameObject.AddComponent <DialogContainer>();
        dialogueBox.Setup(new Vector3(0.0f, -3.5f));

        bool isBossChar = PD.p1Char == PersistData.C.White || PD.p1Char == PersistData.C.September;

        curFrame = (!isBossChar && (PD.level == 6 || PD.level == 8))?0:2;
        StartFrame(curFrame);

        skipButtonSheet = Resources.LoadAll <Sprite>(SpritePaths.ShortButtons);
        skipButton      = GetGameObject(new Vector3(8.3f, -4.75f), "Skip", skipButtonSheet[0], true, "Pause HUD Buttons");
        FontData font = PD.mostCommonFont.Clone(); font.scale = 0.045f;
        XmlNode  top  = GetXMLHead();

        skipText = GetMeshText(new Vector3(8.3f, -4.61f), GetXmlValue(top, "skip"), font).gameObject;
        skipText.renderer.sortingLayerName = "Pause HUD Text";

        mouseObjects.Add(skipButton);
        mouseObjects.Add(skipText);

        skipMenu = GetGameObject(new Vector3(0.0f, 0.0f), "Skip Menu", Resources.Load <Sprite>(SpritePaths.CutsceneSkipBox), false, "HUDText");

        string f = string.Format(GetXmlValue(top, "skipmessage"), "\r\n", PD.controller.GetFriendlyActionName(InputMethod.Action.launch), PD.controller.GetFriendlyActionName(InputMethod.Action.pause));

        font.scale        = 0.08f; font.layerName = "Reference";
        skipMenuText      = GetMeshText(new Vector3(0.0f, 0.5f), f, font);
        skipMenuText.text = new WritingWriter().GetWrappedString(skipMenuText, f, skipMenu.renderer.bounds.size);
        skipMenuText.gameObject.SetActive(false);
        skipMenu.SetActive(false);

        PD.sounds.SetSoundVolume(PD.GetSaveData().savedOptions["vol_s"] / 350.0f);
    }
Exemple #5
0
        /// <summary>
        /// Updates any input to the console
        /// </summary>
        /// <param name="gameTime">The current game time</param>
        public override void Update(GameTime gameTime)
        {
            if (!isEnabled)
            {
#if !XBOX
                //TODO: Needs refactoring
                IGameConsole console = (IGameConsole)Game.Services.GetService(typeof(IGameConsole));
                if (!console.IsOpen && InputCore.IsNewKeyPress(Keys.OemTilde))
                {
                    console.Open(Keys.OemTilde);
                }
#endif

                return;
            }
            mCurrentTime = gameTime;

            // handle cursor blinking
            mCursorTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (mCursorTimer <= 0)
            {
                mDrawCursor  = !mDrawCursor;
                mCursorTimer = mCursorBlinkSpeed + mCursorTimer;
            }

            // handle notify blinking
            mNotifyTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (mNotifyTimer <= 0)
            {
                mDrawNotify  = !mDrawNotify;
                mNotifyTimer = mNotifyBlinkSpeed + mNotifyTimer;
            }

            KeyboardState kb = Keyboard.GetState();

            // Close the console if the close key was pressed
            //if ((kb[mCloseKey] == KeyState.Down)
            //  && (mLastKeyboardState[mCloseKey] == KeyState.Up))
            if (InputCore.IsNewKeyPress(mCloseKey))
            {
                isEnabled = false;
                return;
            }

            // handle input cursor movement if cursor is enabled
            if (mCursorEnabled)
            {
                if ((kb[Keys.Left] == KeyState.Down) && (mLastKeyboardState[Keys.Left] == KeyState.Up))
                {
                    if (mInputPosition > 0)
                    {
                        mInputPosition--;
                    }
                }

                if ((kb[Keys.Right] == KeyState.Down) && (mLastKeyboardState[Keys.Right] == KeyState.Up))
                {
                    if (mInputPosition < mCurrentText.Length)
                    {
                        mInputPosition++;
                    }
                }
            }

            // handle paging up and down
            if ((kb[Keys.PageUp] == KeyState.Down) && (mLastKeyboardState[Keys.PageUp] == KeyState.Up))
            {
                mCurrentLine = (int)MathHelper.Clamp(mCurrentLine - mVisibleLineCount, 0, mLog.Count - 1);
            }

            if ((kb[Keys.PageDown] == KeyState.Down) && (mLastKeyboardState[Keys.PageDown] == KeyState.Up))
            {
                mCurrentLine = (int)MathHelper.Clamp(mCurrentLine + mVisibleLineCount, 0, mLog.Count - 1);
            }

            if ((kb[Keys.Up] == KeyState.Down) && (mLastKeyboardState[Keys.Up] == KeyState.Up))
            {
                mCurrentLine = (int)MathHelper.Clamp(mCurrentLine - 1, 0, mLog.Count - 1);
            }

            if ((kb[Keys.Down] == KeyState.Down) && (mLastKeyboardState[Keys.Down] == KeyState.Up))
            {
                mCurrentLine = (int)MathHelper.Clamp(mCurrentLine + 1, 0, mLog.Count - 1);
            }

            // Process each pressed key for a key down event
            foreach (Keys key in kb.GetPressedKeys())
            {
                // if its a repeat key, skip it
                if (mLastKeyboardState[key] != KeyState.Up)
                {
                    continue;
                }

                char        ch  = new char();
                KeyModifier mod = KeyModifier.None;

                // check for shift modifiers
                if ((kb[Keys.LeftShift] == KeyState.Down) ||
                    (kb[Keys.RightShift] == KeyState.Down))
                {
                    mod = KeyModifier.Shift;
                }

                if (ConsoleKeyMap.GetCharacter(key, mod, ref ch))
                {
                    mCurrentText.Insert(mInputPosition, new char[] { ch });
                    mInputPosition++;
                }
            }

            // check for backspace
            if (kb[Keys.Back] == KeyState.Down && mLastKeyboardState[Keys.Back] == KeyState.Up)
            {
                if (mInputPosition > 0)
                {
                    mCurrentText.Remove(mInputPosition - 1, 1);
                }

                mInputPosition = (int)MathHelper.Clamp(mInputPosition - 1, 0, mCurrentText.Length);
            }

            // check for entered text
            if ((kb[Keys.Enter] == KeyState.Down) && (mLastKeyboardState[Keys.Enter] == KeyState.Up))
            {
                mInputPosition = 0;

                // if the text is length 0, we won't log it
                if (mCurrentText.Length == 0)
                {
                    return;
                }

                // build the current text input string
                string input = mCurrentText.ToString();

                // break the text into a command and arguments for any command handlers that
                // might be registered for it
#if XBOX
                string[] command = input.Split(new char[] { ' ', '\t' });
#else
                string[] command = input.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
#endif
                // nothing useful...
                if (command.Length == 0)
                {
                    return;
                }

                // log it if echo is enabled
                if (mEchoEnabled)
                {
                    Log(input, mEchoLogLevel);
                }

                // let the raw input handlers do their thing
                if (TextEntered != null)
                {
                    TextEntered(input, gameTime);
                }

                // remove the command part from the input, leaving the arguments
                input = input.Remove(0, command[0].Length + ((command.Length > 1) ? (1) : (0)));

                // clear the current text
                mCurrentText.Remove(0, mCurrentText.Length);

                // call any command handlers registered to the command
                if (mCommandHandlers.ContainsKey(command[0]))
                {
                    string[] args = new string[] { input };

                    if (mCommandHandlers[command[0]].ArgumentSeparators.Length > 0)
                    {
#if XBOX
                        args = input.Split(mCommandHandlers[command[0]].ArgumentSeparators);
#else
                        args = input.Split(mCommandHandlers[command[0]].ArgumentSeparators,
                                           StringSplitOptions.RemoveEmptyEntries);
#endif
                    }

                    mCommandHandlers[command[0]].Handler(gameTime, args);
                }
                else if (mAlertOnUnrecognizedCommand)
                {
                    Log(string.Format("Unrecognized Command: '{0}'", command[0]), 0);
                }
            }

            // save last keyboard state
            mLastKeyboardState = kb;

            base.Update(gameTime);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing PadTie...");
            var core = new InputCore(IntPtr.Zero);

            if (core.Controllers.Count == 0)
            {
                Console.WriteLine("No gamepads detected.");
            }
            else
            {
                var vc  = new VirtualController(core);
                var pad = core.Controllers[0];

                pad.Axes[0].Analog = new VirtualController.AxisAction(vc, VirtualController.Axis.LeftX);
                pad.Axes[1].Analog = new VirtualController.AxisAction(vc, VirtualController.Axis.LeftX);
                pad.Axes[2].Analog = new VirtualController.AxisAction(vc, VirtualController.Axis.RightX);
                pad.Axes[3].Analog = new VirtualController.AxisAction(vc, VirtualController.Axis.RightY);

                // Face buttons
                pad.Buttons[0].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.X);
                pad.Buttons[1].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.A);
                pad.Buttons[2].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.B);
                pad.Buttons[3].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.Y);

                // Shoulder buttons
                pad.Buttons[4].Raw  = new VirtualController.ButtonAction(vc, VirtualController.Button.Bl);
                pad.Buttons[5].Raw  = new VirtualController.ButtonAction(vc, VirtualController.Button.Br);
                pad.Buttons[6].Raw  = new VirtualController.ButtonAction(vc, VirtualController.Button.Tl);
                pad.Buttons[7].Raw  = new VirtualController.ButtonAction(vc, VirtualController.Button.Tr);
                pad.Buttons[8].Raw  = new VirtualController.ButtonAction(vc, VirtualController.Button.Back);
                pad.Buttons[9].Raw  = new VirtualController.ButtonAction(vc, VirtualController.Button.Start);
                pad.Buttons[10].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.LeftAnalog);
                pad.Buttons[11].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.RightAnalog);

                /// *************** Real mapping (to virtual controller) **************** ///

                vc.LeftXAxis.Positive.Link = new KeyAction(User32InputHook.VK.VK_RIGHT);
                vc.LeftXAxis.Negative.Link = new KeyAction(User32InputHook.VK.VK_LEFT);
                vc.LeftYAxis.Positive.Link = new KeyAction(User32InputHook.VK.VK_DOWN);
                vc.LeftYAxis.Negative.Link = new KeyAction(User32InputHook.VK.VK_UP);

                vc.LeftXAxis.Positive.Link = new KeyAction('d');
                vc.LeftXAxis.Negative.Link = new KeyAction('a');
                vc.LeftYAxis.Positive.Link = new KeyAction('s');
                vc.LeftYAxis.Negative.Link = new KeyAction('w');

                vc.RightXAxis.Positive.Link = new MousePointerAction(core, 20, 0);
                vc.RightXAxis.Negative.Link = new MousePointerAction(core, -20, 0);
                vc.RightYAxis.Positive.Link = new MousePointerAction(core, 0, 20);
                vc.RightYAxis.Negative.Link = new MousePointerAction(core, 0, -20);

                vc.Br.Link    = new MouseButtonAction(core, MouseButtonAction.Buttons.Left);
                vc.Tr.Link    = new MouseButtonAction(core, MouseButtonAction.Buttons.Right);
                vc.X.Link     = new KeyAction(User32InputHook.VK.VK_SPACE);
                vc.A.Link     = new KeyAction('e');
                vc.Bl.Link    = new MouseWheelAction(core, 26, true);
                vc.Tl.Link    = new MouseWheelAction(core, -26, true);
                vc.Start.Link = new KeyAction(User32InputHook.VK.VK_RETURN);
                vc.Back.Link  = new KeyAction(User32InputHook.VK.VK_ESCAPE);
                vc.Back.Hold  = new KeyAction(User32InputHook.VK.VK_TAB, User32InputHook.VK.VK_MENU);

                Console.WriteLine("Press keys...");
                while (true)
                {
                    core.RunIteration();
                    Thread.Sleep(0);
                }
            }
            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
        }