예제 #1
0
        private void Update()
        {
            if (usePhysicalGamepad)
            {
                debugGamepad.PollInput();
                if (virtualGamepad != null)
                {
                    for (int i = 0; i < debugAxes.Length; i++)
                    {
                        switch (debugAxes[i])
                        {
                        case AxisType.LeftJoystickX:
                        case AxisType.LeftJoystickY:
                        case AxisType.RightJoystickX:
                        case AxisType.RightJoystickY:
                            VirtualGamepadJoystick virtualJoystick = (VirtualGamepadJoystick)virtualGamepad.ControlMap[debugAxes[i]];
                            GamepadJoystick        debugJoystick   = (GamepadJoystick)debugGamepad.ControlMap[debugAxes[i]];

                            if (debugJoystick.Magnitude >= 0.1f)
                            {
                                if (virtualJoystick.JoyStickTouchPhase != TouchPhase.Moved)
                                {
                                    virtualJoystick.OnTouchBegin(TouchPhase.Began, virtualJoystick.transform.position);
                                }

                                virtualJoystick.SetTrackingPosition(debugJoystick.Delta * virtualJoystick.ControlThreshold);
                                virtualJoystick.OnTouchMoved(TouchPhase.Moved, Vector3.zero);
                            }
                            else
                            {
                                virtualJoystick.SetTrackingPosition(Vector3.zero);
                                virtualJoystick.OnTouchMoved(TouchPhase.Moved, Vector3.zero);
                                virtualJoystick.OnTouchEnd(TouchPhase.Ended, Vector3.zero);
                            }

                            break;

                        case AxisType.Button01:
                        case AxisType.Button02:
                        case AxisType.Button03:
                        case AxisType.Button04:
                            VirtualGamepadButton virtualButton = (VirtualGamepadButton)virtualGamepad.ControlMap[debugAxes[i]];
                            GamepadButton        debugButton   = (GamepadButton)debugGamepad.ControlMap[debugAxes[i]];

                            virtualButton.SetValue(debugButton.Value);
                            break;
                        }
                    }
                }
            }
        }
예제 #2
0
파일: Gamepad.cs 프로젝트: ADM87/GameSys
        public Gamepad()
        {
            LeftJoystick  = new GamepadJoystick(AxisType.LeftJoystickX, AxisType.LeftJoystickY);
            RightJoystick = new GamepadJoystick(AxisType.RightJoystickX, AxisType.RightJoystickY);

            Button01 = new GamepadButton(AxisType.Button01);
            Button02 = new GamepadButton(AxisType.Button02);
            Button03 = new GamepadButton(AxisType.Button03);
            Button04 = new GamepadButton(AxisType.Button04);

            ControlMap = new Dictionary <AxisType, IGamepadControl> {
                { AxisType.LeftJoystickX, LeftJoystick },
                { AxisType.LeftJoystickY, LeftJoystick },
                { AxisType.RightJoystickX, RightJoystick },
                { AxisType.RightJoystickY, RightJoystick },
                { AxisType.Button01, Button01 },
                { AxisType.Button02, Button02 },
                { AxisType.Button03, Button03 },
                { AxisType.Button04, Button04 }
            };
        }