当前位置: 首页>>代码示例>>C#>>正文


C# Effect.GetDirection方法代码示例

本文整理汇总了C#中Effect.GetDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.GetDirection方法的具体用法?C# Effect.GetDirection怎么用?C# Effect.GetDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Effect的用法示例。


在下文中一共展示了Effect.GetDirection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connect


//.........这里部分代码省略.........
                device.Properties.AutoCenter = false;
            }

            //Set axis mode absolute.
            device.Properties.AxisModeAbsolute = true;

            //Acquire joystick for capturing.
            device.Acquire();


            //Configure axes
            int[] axis = null;
            foreach (DeviceObjectInstance doi in device.Objects)
            {
                //Set axes ranges.
                if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
                {
                    device.Properties.SetRange(
                    ParameterHow.ById,
                    doi.ObjectId,
                    new InputRange(-5000, 5000));
                }

                int[] temp;

                // Get info about first two FF axii on the device
                if ((doi.Flags & (int)ObjectInstanceFlags.Actuator) != 0)
                {
                    if (axis != null)
                    {
                        temp = new int[axis.Length + 1];
                        axis.CopyTo(temp, 0);
                        axis = temp;
                    }
                    else
                    {
                        axis = new int[1];
                    }

                    // Store the offset of each axis.
                    axis[axis.Length - 1] = doi.Offset;
                    if (axis.Length == 2)
                    {
                        break;
                    }
                }
            }


            //See if joystick supports ConstantForce and set it.

            foreach (EffectInformation ei in device.GetEffects(EffectType.All))
            {
                //If the joystick supports ConstantForce, then apply it.

                if (DInputHelper.GetTypeCode(ei.EffectType)
                    == (int)EffectType.ConstantForce)
                {
                    // Fill in some generic values for the effect.
                    e = new Effect();

                    e.SetDirection(new int[axis.Length]);
                    e.SetAxes(new int[axis.Length]);
                    e.ConditionStruct = new Condition[axis.Length];

                    e.EffectType = EffectType.ConstantForce;
                    
                    e.Constant = new ConstantForce();
                    e.Constant.Magnitude = 10000; 
                    
                    e.Duration = (int)DI.Infinite;
                    e.Gain = 10000;
                    e.SamplePeriod = 0;
                    e.TriggerButton = (int)Microsoft.DirectX.DirectInput.Button.NoTrigger;
                    e.TriggerRepeatInterval = (int)DI.Infinite;
                    e.Flags = EffectFlags.ObjectOffsets | EffectFlags.Cartesian;
                    e.SetAxes(axis);

                    var dd = e.GetDirection();
                    dd[0] = -100;
                    dd[1] = 100;
                    e.SetDirection(dd);


                    // Create the effect, using the passed in guid.
                    eo = new EffectObject(ei.EffectGuid, e, device);

                    eo.Start(1, EffectStartFlags.NoDownload);

                    force_ei = ei;
                    break;
                }
            }

            if (eo == null)
            {
                return JOYSTICK_TYPE.NO_FORCE_FEEDBACK;
            }
            return JOYSTICK_TYPE.FORCE_FEEDBACK;
        }
开发者ID:parhansson,项目名称:KMotionX,代码行数:101,代码来源:ForceFeedbackJoystick.cs


注:本文中的Effect.GetDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。