Exemplo n.º 1
0
        public override void AddStandardControls(ControlSetup setup)
        {
            base.AddStandardControls(setup);

            for (var i = 0; i < kMaxConcurrentTouches; ++i)
            {
                var controls = new TouchControls();
                m_TouchControls.Add(controls);

                var prefix = "Touch " + i;
                controls.isDown    = (ButtonControl)setup.AddControl(SupportedControl.Get <ButtonControl>(prefix));
                controls.fingerId  = (DiscreteStatesControl)setup.AddControl(SupportedControl.Get <DiscreteStatesControl>(prefix + " ID"));
                controls.position  = (Vector2Control)setup.AddControl(SupportedControl.Get <Vector2Control>(prefix + " Position"));
                controls.positionX = (AxisControl)setup.AddControl(SupportedControl.Get <AxisControl>(prefix + " Position X"));
                controls.positionY = (AxisControl)setup.AddControl(SupportedControl.Get <AxisControl>(prefix + " Position Y"));
                controls.delta     = (Vector2Control)setup.AddControl(SupportedControl.Get <Vector2Control>(prefix + " Delta"));
                controls.deltaX    = (DeltaAxisControl)setup.AddControl(SupportedControl.Get <DeltaAxisControl>(prefix + " Delta X"));
                controls.deltaY    = (DeltaAxisControl)setup.AddControl(SupportedControl.Get <DeltaAxisControl>(prefix + " Delta Y"));
                controls.radius    = (Vector2Control)setup.AddControl(SupportedControl.Get <Vector2Control>(prefix + " Radius"));
                controls.radiusX   = (AxisControl)setup.AddControl(SupportedControl.Get <AxisControl>(prefix + " Radius X"));
                controls.radiusY   = (AxisControl)setup.AddControl(SupportedControl.Get <AxisControl>(prefix + " Radius Y"));
                controls.pressure  = (AxisControl)setup.AddControl(SupportedControl.Get <AxisControl>(prefix + " Pressure"));
            }

            setup.GetControl(CommonControls.DoubleClick).name = "Double Tap";
            setup.GetControl(CommonControls.Action1).name     = "One Finger";
            setup.GetControl(CommonControls.Action2).name     = "Two Fingers";
        }
Exemplo n.º 2
0
 public static void HatMapping(this ControlSetup setup, int sourceIndex, SupportedControl left, SupportedControl right, SupportedControl down, SupportedControl up, int startingIndex = 0)
 {
     setup.mappings[sourceIndex] = new ControlHatMapping(
         setup.GetControl(left).index,
         setup.GetControl(right).index,
         setup.GetControl(down).index,
         setup.GetControl(up).index,
         startingIndex);
 }
Exemplo n.º 3
0
        public override void AddStandardControls(ControlSetup setup)
        {
            base.AddStandardControls(setup);

            barrelButton = (ButtonControl)setup.AddControl(CommonControls.Action3);

            setup.GetControl(CommonControls.Action1).name = "Tip";
            setup.GetControl(CommonControls.Action2).name = "Eraser";
            setup.GetControl(CommonControls.Action3).name = "Barrel Button";
        }
Exemplo n.º 4
0
 public static void Mapping(this ControlSetup setup, int sourceIndex, SupportedControl control, Range fromRange, Range toRange)
 {
     setup.mappings[sourceIndex] = new ControlMapping(
         setup.GetControl(control).index,
         fromRange,
         toRange);
 }
Exemplo n.º 5
0
        public override void AddStandardControls(ControlSetup setup)
        {
            base.AddStandardControls(setup);

            setup.GetControl(CommonControls.Pose).name = "IMU Pose";

            devicePosition = (Vector3Control)setup.AddControl(SupportedControl.Get <Vector3Control>("Device Position"));
            deviceRotation = (QuaternionControl)setup.AddControl(SupportedControl.Get <QuaternionControl>("Device Rotation"));
            devicePose     = (PoseControl)setup.AddControl(SupportedControl.Get <PoseControl>("Device Pose"));

            displayPosition = (Vector3Control)setup.AddControl(SupportedControl.Get <Vector3Control>("Display Position"));
            displayRotation = (QuaternionControl)setup.AddControl(SupportedControl.Get <QuaternionControl>("Display Rotation"));
            displayPose     = (PoseControl)setup.AddControl(SupportedControl.Get <PoseControl>("Display Pose"));

            colorCameraPosition = (Vector3Control)setup.AddControl(SupportedControl.Get <Vector3Control>("Color Camera Position"));
            colorCameraRotation = (QuaternionControl)setup.AddControl(SupportedControl.Get <QuaternionControl>("Color Camera Rotation"));
            colorCameraPose     = (PoseControl)setup.AddControl(SupportedControl.Get <PoseControl>("Color Camera Pose"));

            depthCameraPosition = (Vector3Control)setup.AddControl(SupportedControl.Get <Vector3Control>("Depth Camera Position"));
            depthCameraRotation = (QuaternionControl)setup.AddControl(SupportedControl.Get <QuaternionControl>("Depth Camera Rotation"));
            depthCameraPose     = (PoseControl)setup.AddControl(SupportedControl.Get <PoseControl>("Depth Camera Pose"));

            fisheyeCameraPosition = (Vector3Control)setup.AddControl(SupportedControl.Get <Vector3Control>("Fisheye Camera Position"));
            fisheyeCameraRotation = (QuaternionControl)setup.AddControl(SupportedControl.Get <QuaternionControl>("Fisheye Camera Rotation"));
            fisheyeCameraPose     = (PoseControl)setup.AddControl(SupportedControl.Get <PoseControl>("Fisheye Camera Pose"));
        }
Exemplo n.º 6
0
        public override void AddStandardControls(ControlSetup setup)
        {
            base.AddStandardControls(setup);

            middleButton = (ButtonControl)setup.AddControl(CommonControls.Action3);

            scrollWheel  = (Vector2Control)setup.AddControl(CommonControls.ScrollWheel2d);
            scrollWheelX = (AxisControl)setup.AddControl(CommonControls.ScrollWheelX);
            scrollWheelY = (AxisControl)setup.AddControl(CommonControls.ScrollWheelY);

            setup.GetControl(CommonControls.Action1).name = "Left Button";
            setup.GetControl(CommonControls.Action2).name = "Right Button";
            setup.GetControl(CommonControls.Action3).name = "Middle Button";

            setup.GetControl(CommonControls.ScrollWheelX).name = "Scroll Horizontal";
            setup.GetControl(CommonControls.ScrollWheelY).name = "Scroll Vertical";
        }
        public override ControlSetup GetControlSetup(InputDevice device)
        {
            ControlSetup setup = new ControlSetup(device);

            setup.AddControl(CommonControls.Back);
            setup.AddControl(CommonControls.Start);

            // Add the two additional motors on the triggers.
            var leftTriggerMotor  = new AxisOutput("Left Trigger Vibration");
            var rightTriggerMotor = new AxisOutput("Right Trigger Vibration");

            setup.AddControl(SupportedControl.Get <AxisOutput>("Left Trigger Vibration"), leftTriggerMotor);
            setup.AddControl(SupportedControl.Get <AxisOutput>("Right Trigger Vibration"), rightTriggerMotor);

            // Section for control name overrides.
            setup.GetControl(CommonControls.Action1).name = "A";
            setup.GetControl(CommonControls.Action2).name = "B";
            setup.GetControl(CommonControls.Action3).name = "X";
            setup.GetControl(CommonControls.Action4).name = "Y";

            return(setup);
        }
        public override void AddStandardControls(ControlSetup setup)
        {
            base.AddStandardControls(setup);

            setup.GetControl(CommonControls.Pose).name = "Head Pose";

            leftEyePosition = (Vector3Control)setup.AddControl(SupportedControl.Get <Vector3Control>("Left Eye Position"));
            leftEyeRotation = (QuaternionControl)setup.AddControl(SupportedControl.Get <QuaternionControl>("Left Eye Rotation"));
            leftEyePose     = (PoseControl)setup.AddControl(SupportedControl.Get <PoseControl>("Left Eye Pose"));

            rightEyePosition = (Vector3Control)setup.AddControl(SupportedControl.Get <Vector3Control>("Right Eye Position"));
            rightEyeRotation = (QuaternionControl)setup.AddControl(SupportedControl.Get <QuaternionControl>("Right Eye Rotation"));
            rightEyePose     = (PoseControl)setup.AddControl(SupportedControl.Get <PoseControl>("Right Eye Pose"));

            centerEyePosition = (Vector3Control)setup.AddControl(SupportedControl.Get <Vector3Control>("Center Eye Position"));
            centerEyeRotation = (QuaternionControl)setup.AddControl(SupportedControl.Get <QuaternionControl>("Center Eye Rotation"));
            centerEyePose     = (PoseControl)setup.AddControl(SupportedControl.Get <PoseControl>("Center Eye Pose"));
        }
Exemplo n.º 9
0
 public static void Mapping(this ControlSetup setup, int sourceIndex, SupportedControl control)
 {
     setup.mappings[sourceIndex] = new ControlMapping(
         setup.GetControl(control).index);
 }
Exemplo n.º 10
0
 public static void SplitMapping(this ControlSetup setup, int sourceIndex, SupportedControl negative, SupportedControl positive)
 {
     setup.mappings[sourceIndex] = new ControlSplitMapping(
         setup.GetControl(negative).index,
         setup.GetControl(positive).index);
 }
        public XboxHIDGamepadProfile()
        {
            name = "Xbox Controller";
            matchingDeviceRegexes = new List <string>()
            {
                // Windows (XInput devices rely on a common product format of 'Product:[Controller(...)]')
                "^(?=.*product:(?=.*Controller \\(.*\\)))(?=.*interface:.*\\[HID\\])(?=.*type:.*HID.*Page:0x1.*Id:0x5).*$",
                // OSX
                "^(?=.*product:(?=.*Controller)(?=.*Xbox))(?=.*interface:.*\\[HID\\])(?=.*type:.*HID.*Page:0x1.*Id:0x5).*$",
            };

            ControlSetup setup = GetControlSetup(new Gamepad());

            // Setup mapping.
            setup.SplitMapping(0x010030, CommonControls.LeftStickLeft, CommonControls.LeftStickRight);
            setup.SplitMapping(0x010031, CommonControls.LeftStickUp, CommonControls.LeftStickDown);

            setup.SplitMapping(0x010033, CommonControls.RightStickLeft, CommonControls.RightStickRight);
            setup.SplitMapping(0x010034, CommonControls.RightStickUp, CommonControls.RightStickDown);

            setup.Mapping(0x090001, CommonControls.Action1);
            setup.Mapping(0x090002, CommonControls.Action2);
            setup.Mapping(0x090003, CommonControls.Action3);
            setup.Mapping(0x090004, CommonControls.Action4);

            setup.Mapping(0x090005, CommonControls.LeftBumper);
            setup.Mapping(0x090006, CommonControls.RightBumper);

#if IS_WINDOWS
            // Triggers are combined into a single [-1..1] range. Left is positive, right is negative.
            // At the USB level, the controller properly splits the triggers. XInput is picking it up from there.
            // Unfortunately, the MS HID driver for Xbox controllers combines them.
            setup.SplitMapping(0x010032, CommonControls.RightTrigger, CommonControls.LeftTrigger);

            setup.Mapping(0x090009, CommonControls.LeftStickButton);
            setup.Mapping(0x09000A, CommonControls.RightStickButton);

            setup.Mapping(0x090007, CommonControls.Back);
            setup.Mapping(0x090008, CommonControls.Start);

            // The dpad is done as a HID hatswitch.  The Xbox Hat Switch data is 1-based as it's starting value
            setup.HatMapping(0x010039, CommonControls.DPadLeft, CommonControls.DPadRight, CommonControls.DPadDown, CommonControls.DPadUp, 1);
#else
            setup.Mapping(0x010032, CommonControls.LeftTrigger, Range.full, Range.positive);
            setup.Mapping(0x010035, CommonControls.RightTrigger, Range.full, Range.positive);

            setup.Mapping(0x090007, CommonControls.LeftStickButton);
            setup.Mapping(0x090008, CommonControls.RightStickButton);

            setup.Mapping(0x09000A, CommonControls.Back);
            setup.Mapping(0x090009, CommonControls.Start);

            setup.Mapping(0x09000C, CommonControls.DPadUp, Range.full, Range.positive);
            setup.Mapping(0x09000D, CommonControls.DPadDown, Range.full, Range.positive);
            setup.Mapping(0x09000E, CommonControls.DPadLeft, Range.full, Range.positive);
            setup.Mapping(0x09000F, CommonControls.DPadRight, Range.full, Range.positive);
#endif

            mappings = setup.FinishMappings();

            // Haptics right now only works on Windows, but we intend to extend that to OSX/Linux in the near term.
#if IS_WINDOWS
            hapticsProcessor = new XboxHIDHapticsProcessor(setup.GetControl(SupportedControl.Get <AxisOutput>("Left Vibration")).index,
                                                           setup.GetControl(SupportedControl.Get <AxisOutput>("Right Vibration")).index,
                                                           setup.GetControl(SupportedControl.Get <AxisOutput>("Left Trigger Vibration")).index,
                                                           setup.GetControl(SupportedControl.Get <AxisOutput>("Right Trigger Vibration")).index);
#endif
        }