コード例 #1
0
ファイル: Pointer.cs プロジェクト: funnelle/FallGameJam
        protected override void FinishSetup(InputDeviceBuilder builder)
        {
            position     = builder.GetControl <Vector2Control>(this, "position");
            delta        = builder.GetControl <Vector2Control>(this, "delta");
            tilt         = builder.GetControl <Vector2Control>(this, "tilt");
            radius       = builder.GetControl <Vector2Control>(this, "radius");
            pressure     = builder.GetControl <AxisControl>(this, "pressure");
            twist        = builder.GetControl <AxisControl>(this, "twist");
            pointerId    = builder.GetControl <IntegerControl>(this, "pointerId");
            phase        = builder.GetControl <PointerPhaseControl>(this, "phase");
            displayIndex = builder.GetControl <IntegerControl>(this, "displayIndex");
            button       = builder.GetControl <ButtonControl>(this, "button");

            base.FinishSetup(builder);
        }
コード例 #2
0
        public static void BuildXYCircularInputBasedOnAxisInput(
            ButtonControl controlLeft,
            ButtonControl controlRight,
            ButtonControl controlDown,
            ButtonControl controlUp,
            AxisControl controlX,
            AxisControl controlY,
            Vector2Control control,
            Range deadZones
            )
        {
            // Calculate new vector.
            Vector2 vector = new Vector2(
                -controlLeft.rawValue + controlRight.rawValue,
                -controlDown.rawValue + controlUp.rawValue);

            // Set raw control values.
            control.rawValue  = vector;
            controlX.rawValue = vector.x;
            controlY.rawValue = vector.y;

            // Apply deadzones.
            float magnitude    = vector.magnitude;
            float newMagnitude = GetDeadZoneAdjustedValue(magnitude, deadZones);

            if (newMagnitude == 0)
            {
                vector = Vector2.zero;
            }
            else
            {
                vector *= (newMagnitude / magnitude);
            }

            // Set control values.
            control.value      = vector;
            controlX.value     = vector.x;
            controlY.value     = vector.y;
            controlLeft.value  = Mathf.Max(0, -vector.x);
            controlRight.value = Mathf.Max(0, vector.x);
            controlDown.value  = Mathf.Max(0, -vector.y);
            controlUp.value    = Mathf.Max(0, vector.y);
        }
コード例 #3
0
ファイル: Keyboard.cs プロジェクト: xiawei32/InputSystem
        protected override void FinishSetup(InputDeviceBuilder builder)
        {
            anyKey            = builder.GetControl <AnyKeyControl>("anyKey");
            spaceKey          = builder.GetControl <KeyControl>("space");
            enterKey          = builder.GetControl <KeyControl>("enter");
            tabKey            = builder.GetControl <KeyControl>("tab");
            backquoteKey      = builder.GetControl <KeyControl>("backquote");
            quoteKey          = builder.GetControl <KeyControl>("quote");
            semicolonKey      = builder.GetControl <KeyControl>("semicolon");
            commaKey          = builder.GetControl <KeyControl>("comma");
            periodKey         = builder.GetControl <KeyControl>("period");
            slashKey          = builder.GetControl <KeyControl>("slash");
            backslashKey      = builder.GetControl <KeyControl>("backslash");
            leftBracketKey    = builder.GetControl <KeyControl>("leftBracket");
            rightBracketKey   = builder.GetControl <KeyControl>("rightBracket");
            minusKey          = builder.GetControl <KeyControl>("minus");
            equalsKey         = builder.GetControl <KeyControl>("equals");
            aKey              = builder.GetControl <KeyControl>("a");
            bKey              = builder.GetControl <KeyControl>("b");
            cKey              = builder.GetControl <KeyControl>("c");
            dKey              = builder.GetControl <KeyControl>("d");
            eKey              = builder.GetControl <KeyControl>("e");
            fKey              = builder.GetControl <KeyControl>("f");
            gKey              = builder.GetControl <KeyControl>("g");
            hKey              = builder.GetControl <KeyControl>("h");
            iKey              = builder.GetControl <KeyControl>("i");
            jKey              = builder.GetControl <KeyControl>("j");
            kKey              = builder.GetControl <KeyControl>("k");
            lKey              = builder.GetControl <KeyControl>("l");
            mKey              = builder.GetControl <KeyControl>("m");
            nKey              = builder.GetControl <KeyControl>("n");
            oKey              = builder.GetControl <KeyControl>("o");
            pKey              = builder.GetControl <KeyControl>("p");
            qKey              = builder.GetControl <KeyControl>("q");
            rKey              = builder.GetControl <KeyControl>("r");
            sKey              = builder.GetControl <KeyControl>("s");
            tKey              = builder.GetControl <KeyControl>("t");
            uKey              = builder.GetControl <KeyControl>("u");
            vKey              = builder.GetControl <KeyControl>("v");
            wKey              = builder.GetControl <KeyControl>("w");
            xKey              = builder.GetControl <KeyControl>("x");
            yKey              = builder.GetControl <KeyControl>("y");
            zKey              = builder.GetControl <KeyControl>("z");
            digit1Key         = builder.GetControl <KeyControl>("1");
            digit2Key         = builder.GetControl <KeyControl>("2");
            digit3Key         = builder.GetControl <KeyControl>("3");
            digit4Key         = builder.GetControl <KeyControl>("4");
            digit5Key         = builder.GetControl <KeyControl>("5");
            digit6Key         = builder.GetControl <KeyControl>("6");
            digit7Key         = builder.GetControl <KeyControl>("7");
            digit8Key         = builder.GetControl <KeyControl>("8");
            digit9Key         = builder.GetControl <KeyControl>("9");
            digit0Key         = builder.GetControl <KeyControl>("0");
            leftShiftKey      = builder.GetControl <KeyControl>("leftShift");
            rightShiftKey     = builder.GetControl <KeyControl>("rightShift");
            leftAltKey        = builder.GetControl <KeyControl>("leftAlt");
            rightAltKey       = builder.GetControl <KeyControl>("rightAlt");
            leftCtrlKey       = builder.GetControl <KeyControl>("leftCtrl");
            rightCtrlKey      = builder.GetControl <KeyControl>("rightCtrl");
            leftMetaKey       = builder.GetControl <KeyControl>("leftMeta");
            rightMetaKey      = builder.GetControl <KeyControl>("rightMeta");
            leftWindowsKey    = builder.GetControl <KeyControl>("leftWindows");
            rightWindowsKey   = builder.GetControl <KeyControl>("rightWindows");
            leftAppleKey      = builder.GetControl <KeyControl>("leftApple");
            rightAppleKey     = builder.GetControl <KeyControl>("rightApple");
            leftCommandKey    = builder.GetControl <KeyControl>("leftCommand");
            rightCommandKey   = builder.GetControl <KeyControl>("rightCommand");
            contextMenuKey    = builder.GetControl <KeyControl>("contextMenu");
            escapeKey         = builder.GetControl <KeyControl>("escape");
            leftArrowKey      = builder.GetControl <KeyControl>("leftArrow");
            rightArrowKey     = builder.GetControl <KeyControl>("rightArrow");
            upArrowKey        = builder.GetControl <KeyControl>("upArrow");
            downArrowKey      = builder.GetControl <KeyControl>("downArrow");
            backspaceKey      = builder.GetControl <KeyControl>("backspace");
            pageDownKey       = builder.GetControl <KeyControl>("pageDown");
            pageUpKey         = builder.GetControl <KeyControl>("pageUp");
            homeKey           = builder.GetControl <KeyControl>("home");
            endKey            = builder.GetControl <KeyControl>("end");
            insertKey         = builder.GetControl <KeyControl>("insert");
            deleteKey         = builder.GetControl <KeyControl>("delete");
            numpadEnterKey    = builder.GetControl <KeyControl>("numpadEnter");
            numpadDivideKey   = builder.GetControl <KeyControl>("numpadDivide");
            numpadMultiplyKey = builder.GetControl <KeyControl>("numpadMultiply");
            numpadPlusKey     = builder.GetControl <KeyControl>("numpadPlus");
            numpadMinusKey    = builder.GetControl <KeyControl>("numpadMinus");
            numpadPeriodKey   = builder.GetControl <KeyControl>("numpadPeriod");
            numpadEqualsKey   = builder.GetControl <KeyControl>("numpadEquals");
            numpad0Key        = builder.GetControl <KeyControl>("numpad0");
            numpad1Key        = builder.GetControl <KeyControl>("numpad1");
            numpad2Key        = builder.GetControl <KeyControl>("numpad2");
            numpad3Key        = builder.GetControl <KeyControl>("numpad3");
            numpad4Key        = builder.GetControl <KeyControl>("numpad4");
            numpad5Key        = builder.GetControl <KeyControl>("numpad5");
            numpad6Key        = builder.GetControl <KeyControl>("numpad6");
            numpad7Key        = builder.GetControl <KeyControl>("numpad7");
            numpad8Key        = builder.GetControl <KeyControl>("numpad8");
            numpad9Key        = builder.GetControl <KeyControl>("numpad9");
            f1Key             = builder.GetControl <KeyControl>("f1");
            f2Key             = builder.GetControl <KeyControl>("f2");
            f3Key             = builder.GetControl <KeyControl>("f3");
            f4Key             = builder.GetControl <KeyControl>("f4");
            f5Key             = builder.GetControl <KeyControl>("f5");
            f6Key             = builder.GetControl <KeyControl>("f6");
            f7Key             = builder.GetControl <KeyControl>("f7");
            f8Key             = builder.GetControl <KeyControl>("f8");
            f9Key             = builder.GetControl <KeyControl>("f9");
            f10Key            = builder.GetControl <KeyControl>("f10");
            f11Key            = builder.GetControl <KeyControl>("f11");
            f12Key            = builder.GetControl <KeyControl>("f12");
            capsLockKey       = builder.GetControl <KeyControl>("capsLock");
            numLockKey        = builder.GetControl <KeyControl>("numLock");
            scrollLockKey     = builder.GetControl <KeyControl>("scrollLock");
            printScreenKey    = builder.GetControl <KeyControl>("printScreen");
            pauseKey          = builder.GetControl <KeyControl>("pause");
            oem1Key           = builder.GetControl <KeyControl>("OEM1");
            oem2Key           = builder.GetControl <KeyControl>("OEM2");
            oem3Key           = builder.GetControl <KeyControl>("OEM3");
            oem4Key           = builder.GetControl <KeyControl>("OEM4");
            oem5Key           = builder.GetControl <KeyControl>("OEM5");

            imeSelected = builder.GetControl <ButtonControl>("IMESelected");

            ////REVIEW: Ideally, we'd have a way to do this through layouts; this way nested key controls could work, too,
            ////        and it just seems somewhat dirty to jam the data into the control here

            // Assign key code to all keys.
            for (var key = 1; key < (int)Keyboard.KeyCount; ++key)
            {
                this[(Key)key].keyCode = (Key)key;
            }

            base.FinishSetup(builder);
        }
コード例 #4
0
 // ReSharper disable once MemberCanBeProtected.Global
 public void Release(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
 {
     Set(button, 0, absoluteTime, timeOffset);
 }
コード例 #5
0
 // ReSharper disable once MemberCanBeProtected.Global
 public void Press(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
 {
     Set(button, 1, absoluteTime, timeOffset);
 }
コード例 #6
0
 public void PressAndRelease(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
 {
     Press(button, absoluteTime, timeOffset);
     Release(button, absoluteTime, timeOffset);
 }